如何在xPath中检查类型是否等于类型或从类型派生 [英] How to check in xPath if a type is equal to a type or derived from the type

查看:92
本文介绍了如何在xPath中检查类型是否等于类型或从类型派生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Schematron中使用xPath.我能够检查类型是否等于目标类型.例如,"xsd:string eq xsd:string".

I'm working with xPath inside Schematron. I'm able to check that a type is equal to a target type. For example '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?我已经尝试过:

How can I check if a type defined by the user, which has been derived from xsd:string? I've tried:

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

但这不起作用.

推荐答案

没有公开的XPath 2.0功能.实际上,XPath 2.0类型不是一流的值.无法从仅在运行时知道的名称中查找类型,也无法要求类型的属性.您将需要使用扩展:Xerces和Saxon都具有用于询问架构组件的API,并且可以构造调用这些组件的Java扩展函数.

There's no exposed XPath 2.0 functionality for doing this. In fact XPath 2.0 types aren't first-class values; there is no way of finding a type from a name known only at run-time, or asking for properties of the type. You'll need to use extensions: both Xerces and Saxon have APIs for interrogating schema components, and you could construct Java extension functions that invoke these.

这篇关于如何在xPath中检查类型是否等于类型或从类型派生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆