生成Schematron中的”see”属性值

huangapple go评论49阅读模式
英文:

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.

生成Schematron中的”see”属性值

答案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=&quot;{$x}&quot; in Schematron then generates an SVRL report having the URI in the form of e.g.

&lt;svrl:successful-report location=&quot;/&quot; see=&quot;http://www.b.com&quot; test=&quot;&#39;a&#39; = &#39;a&#39;&quot;&gt;
  &lt;svrl:text&gt;
            Hello world
        &lt;/svrl:text&gt;
&lt;/svrl:successful-report&gt;

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

  1. 在您的Schematron文件中使用 xsl:include 包含XSLT。参见,例如,https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L23
  2. 在外部XSLT文件中编写一个返回 "user.home" 系统属性值的函数
  3. 在Schematron中的 rule 中,使用 let 获取函数的返回值作为变量值。参见,例如,https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L31
  4. 像任何其他变量一样,在您的 assertreport 中使用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:

  1. 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
  2. Write a function in the external XSLT that returns the "user.home" system property value
  3. In your rule in your Schematron, use let 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
  4. Use the Schematron variable in your assert and report just like any other variable

huangapple
  • 本文由 发表于 2023年2月6日 19:11:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/75360548.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定