【问题标题】:How to check in xPath if a type is equal to a type or derived from the type如果类型等于某个类型或从该类型派生,如何检查 xPath
【发布时间】:2011-11-30 09:11:37
【问题描述】:

我正在使用 Schematron 中的 xPath。我能够检查一个类型是否等于一个目标类型。例如'xsd:string eq xsd:string'。

<sch:rule context="uis:variable/uis:dependency/uis:length">
<sch:assert test="**../../@type eq 'xsd:string'**">      
Text        
</sch:assert>                       
</sch:rule>

如何检查用户定义的类型是否派生自 xsd:string?我试过了:

<sch:rule context="uis:variable/uis:dependency/uis:length">
<sch:assert test="**../../@type instance of attribute (*,xsd:string)**">
Text        
</sch:assert>                       
</sch:rule>

但它不起作用。

【问题讨论】:

    标签: xml xpath xsd schematron


    【解决方案1】:

    没有公开的 XPath 2.0 功能用于执行此操作。事实上,XPath 2.0 类型不是一等值;无法从仅在运行时知道的名称中找到类型,也无法要求类型的属性。您需要使用扩展:Xerces 和 Saxon 都有用于询问模式组件的 API,您可以构建调用这些 API 的 Java 扩展函数。

    【讨论】:

    • 谢谢迈克尔,我会看看你的建议。
    猜你喜欢
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多