strubel at photonfocus.com wrote: > This question might not be related to XXE, but I am sure the gurus know > an answer: > > I have a 'generic' node <property> where I want to encode its data type > in a 'type' attribute. The allowed content of this node is depending on > this type attribute, for example: > > <property type="ARRAY"> > <size>4</size> > </property> > > In case of > > <property type="FLOAT"> > > I don't want <size> to be allowed by the schema, neither I would want a > special <array> node, because this would complicate my XSLT stylesheets. > > I couldn't yet figure out a way how to do that in XSD, however I've > observed that XXE is able to do so when validating schema XSD files (for > example: try specifying 'type' attribute AND child 'complexType', which > should be mutually exclusive)
Using DTDs or W3C XML Schemas, there is *no way* to allow or forbid a child element such as "size" depending on the value of attribute "type" of parent element "property". To my knowledge, only Relax NG -- http://www.relaxng.org/ -- allows to do specify this; and Relax NG is unfortunately not yet supported by XXE. We recommend to make your schema more strongly typed, that is to define a special <array> node. However, if you really don't want to do that and if you can program in Java, it is pretty easy to write a DocumentHook which is invoked by XXE just after the validation by the DTD or the W3C XML Schema (among other things). A DocumentHook, see http://www.xmlmind.com/xmleditor/_distrib/docs/dev/ar01s08.html, has mainly been designed to allow to perform a semantic validation which goes beyond what can be done by DTDs and W3C XML Schemas alone. --- PS: If you create a W3C XML Schema in XXE and you specify both a "type" attribute and a "xs:complexType" child element for an "xs:element", you get a *semantic* error detected by the ``built-in DocumentHook for W3C XML Schemas'' and not a *structural* error detected by the standard validation by the Schema for Schemas.

