英文:
Generate Schematron "see" attribute value
问题
我想根据用户主目录动态生成Schematron中的see
属性。但是我无法使其正常工作。您是否有想法是否可能实现这一点?它需要在Oxygen XML中运行。我不确定这在技术上是否不可能在Schematron中实现,还是这是Oxygen XML中的一个错误。
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:pattern>
<sch:rule context="/">
<sch:let name="x" value="if (contains(base-uri(), 'myname'))
then 'http://www.a.com'
else 'http://www.b.com'"/>
<sch:report test="'a' = 'a'">
Hello world: "<sch:value-of select="$x"/>"
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
我的目标是生成一个特定于用户的链接,指向本地部署的样式指南,但如您在屏幕截图中所见,变量x
没有解析。
英文:
I would like to dynamically generate the Schematron see
attribute based on the the user home's directory. I could not get this working. Do you have an idea if this is possible? It needs to work in Oxygen XML. I am not sure if this is technically not possible in Schematron, or if this is a bug in Oxygen XML.
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:pattern>
<sch:rule context="/">
<sch:let name="x" value="if (contains(base-uri(), 'myname'))
then 'http://www.a.com'
else 'http://www.b.com'"/>
<sch:report test="'a' = 'a'">
Hello world: "<sch:value-of select="$x"/>"
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
My goal is to generate a user-specific link to a locally deployed style guide, but, as you can see in the screenshot, the variable x
is not resolved.
答案1
得分: 1
你可以尝试读取“user.home”系统属性:https://www.saxonica.com/html/documentation12/functions/fn/system-property.html
英文:
Maybe you can try to read the “user.home” system property: https://www.saxonica.com/html/documentation12/functions/fn/system-property.html
答案2
得分: 1
使用Schxslt,似乎在Schematron中的XSLT属性值模板的语法,例如see="{$x}"
,会生成形如以下的SVRL报告,其中URI的形式如下:
<svrl:successful-report location="/"
see="http://www.b.com"
test="'a' = 'a'">
<svrl:text>
Hello world
</svrl:text>
</svrl:successful-report>
我不知道oXygen是否有与Schxslt的集成,可以将其用作Schematron验证工具,并以SVRL的形式呈现验证结果。
英文:
Using Schxslt it seems the syntax of an XSLT attribute value template in the form of e.g. see="{$x}"
in Schematron then generates an SVRL report having the URI in the form of e.g.
<svrl:successful-report location="/" see="http://www.b.com" test="'a' = 'a'">
<svrl:text>
Hello world
</svrl:text>
</svrl:successful-report>
I don't know whether oXygen has any integration for Schxslt as a Schematron validator and for rendering the validation result in the form of SVRL.
答案3
得分: 1
- 在您的Schematron文件中使用
xsl:include
包含XSLT。参见,例如,https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L23 - 在外部XSLT文件中编写一个返回 "user.home" 系统属性值的函数
- 在Schematron中的
rule
中,使用let
获取函数的返回值作为变量值。参见,例如,https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L31 - 像任何其他变量一样,在您的
assert
和report
中使用Schematron变量。
英文:
To build on the answer by @radu-coravu, you might be able to get the 'user.home' value by using a function in an external XSLT file:
- Use
xsl:include
in your Schematron file to include the XSLT. See, e.g., https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L23 - Write a function in the external XSLT that returns the "user.home" system property value
- In your
rule
in your Schematron, uselet
to get the return value of the function as a variable value. See, e.g., https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L31 - Use the Schematron variable in your
assert
andreport
just like any other variable
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论