- From: Michael Kay <mike@saxonica.com>
- Date: Thu, 19 Nov 2015 21:18:59 +0000
- To: "Costello, Roger L." <costello@mitre.org>
- Cc: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
The XSD 1.0 spec says that the {type declaration} of an {element declaration} is: The type definition corresponding to the <simpleType> or <complexType> element information item in the [children], if either is present, otherwise the type definition ·resolved· to by the ·actual value· of the type [attribute], otherwise the {type definition} of the element declaration ·resolved· to by the ·actual value· of the substitutionGroup [attribute], if present, otherwise the ·ur-type definition·. So I don't know where you got @ref and @fixed from, and you've missed out @substitutionGroup. Extracting schema information from raw XSD documents is quite tricky, and I usually advise against it: it's better generally to access the schema component model output by a schema processor. There's also an edge case you have missed, inevitably: //xs:element will select an xs:element element appearing as a descendant of xs:annotation, but such an element does not constitute an element declaration. Michael Kay Saxonica > On 19 Nov 2015, at 20:34, Costello, Roger L. <costello@mitre.org> wrote: > > Hi Folks, > > This element does not specify a type: > > <element name="foo" /> > > Consequently, in instance documents the content of <foo> can be any elements and any text. > > I am trying to create an XPath expression that, when evaluated, returns all element declarations in a schema file that do not specify a type. > > Here's the XPath expression that I created: > > //xs:element[ not(@type) and > not(xs:simpleType) and > not(xs:complexType) and > not(@ref) and > not(@fixed)] > > Will that catch all the elements? Are there any "edge cases" that it misses? > > /Roger >
Received on Thursday, 19 November 2015 21:20:01 UTC