3

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.

james.garriss
  • 12,959
  • 7
  • 83
  • 96

1 Answers1

4

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.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164