I think it may be possible to write a XPath 2.0 conditional use case with XSD 1.1 <assert> and the <pattern> facet. Here's an example,
XSD document <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="P1"> <xs:restriction base="xs:string"> <xs:pattern value="[0-9]+"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="P2"> <xs:restriction base="xs:string"> <xs:pattern value="[a-z]+"/> </xs:restriction> </xs:simpleType> <xs:element name="X1"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="a1" type="xs:boolean"/> <xs:assert test="if (@a1 eq true()) then (. castable as P1) else (. castable as P2)"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:schema> This would validate something like, <X1 a1="0">abc</X1> The issue you reported may be a big with our validator. For our implementation, I think deeper analysis is needed to study specification of fn:matches function, regex grammar of XSD and JDK's Regex pattern behaviors. On 26 July 2014 18:06, Timothy W. Cook <[email protected]> wrote: > Thanks for updating us on this. Certainly the pattern facet could be used > in this case where it is only a pattern match. But with more complex > examples you may need to select between patterns match based on some > condition. My concern was is this a regex processing issue in the > validator? So I chose to report it. Especially since SaxonEE does validate > it. > > Cheers, > Tim > > > -- > Regards, > Mukul Gandhi >
