Costello, Roger L. costello(_at_)mitre(_dot_)org wrote:
Hi Folks,
I seek an XPath 2.0 expression that returns all XML Schema simpleTypes
containing a union with memberTypes containing the XML Schema string type.
(Phew! Did you catch all that?)
So, the XPath should return the union simpleType in this schema:
----------------------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="test">
<xs:union memberTypes="xs:int xs:string" />
</xs:simpleType>
</xs:schema>
----------------------------------------------------------------------------------
The XPath should not return the union simpleType in this schema:
----------------------------------------------------------------------------------
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="test">
<xs:union memberTypes="xs:int string"/>
</xs:simpleType>
<xs:simpleType name="string">
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:schema>
----------------------------------------------------------------------------------
I created a horrendously complex XPath 2.0 expression. I think it works (it's
so complex, I'm not sure). Is there a simpler XPath 2.0 expression to solve
this problem?
Here's the ugly XPath 2.0 expression that I created:
//xs:simpleType[xs:union[@memberTypes]
[exists(index-of(for $here in ., $i in tokenize(@memberTypes, '\s+')
return
namespace-uri-from-QName(resolve-QName($i, $here)) eq
'http://www.w3.org/2001/XMLSchema' and
local-name-from-QName(resolve-QName($i, $here)) eq 'string', true()))]]
I think there is an equality comparison for QNames
//xs:simpleType[xs:union[@memberTypes][some $type in
tokenize(@memberTypes, '\s+') satisfies resolve-QName($type, .) eq
QName('http://www.w3.org/2001/XMLSchema', 'string')]]
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--