user1072936
user1072936

Reputation: 46

How to check in xPath if a type is equal to a type or derived from the type

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>

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>

But it does't work.

Upvotes: 3

Views: 631

Answers (1)

Michael Kay
Michael Kay

Reputation: 163625

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.

Upvotes: 4

Related Questions