Project

Profile

Help

Limitation of XSD 1.0 with same name siblings

Added by Anonymous about 14 years ago

Legacy ID: #8038040 Legacy Poster: Ross B. (rossbrower)

I have the following output from an application, I want to define a schema such that all expected nodes and properties are present and that the types are correct. I had no problem defining complex types with extensions to validate the property types but unfortunately, it looks like xsd will not allow me to treat sibling elements with the same name ("property" in this case) as separate types. Therefore I cannot validate that each expected property is present or that the data is valid. My only thoughts so far on how to resolve this is to transform the below into an intermediate form such that each node and property uses its name attribute as the element name, which has also been problematic. Any ideas/suggestions are welcome. [quote] [/quote]


Replies (2)

RE: Limitation of XSD 1.0 with same name siblings - Added by Anonymous about 14 years ago

Legacy ID: #8040138 Legacy Poster: Michael Kay (mhkay)

Yes, this is a limitation of XSD 1.0. If you're in a position to consider using the XSD 1.1 facilities that are implemented in Saxon-EE 9.2, you can validate this document using the facility knows as "conditional type assignment" where the type assigned to a property element depends on the value of its "name" attribute. Alternatively, as you suggest, you could do validation by first transforming to a structure in which becomes <property.X name="Y">, and then validating this transformed structure.

RE: Limitation of XSD 1.0 with same name siblings - Added by Anonymous about 14 years ago

Legacy ID: #8047076 Legacy Poster: Ross B. (rossbrower)

Well I see we think alike: <xsl:template match="node"> <xsl:element name="node.{@name}" > <xsl:copy-of select="@"/> <xsl:apply-templates select="property" /> <xsl:apply-templates select="node" /> </xsl:element> </xsl:template> <xsl:template match="property"> <xsl:element name="property.{@name}" > <xsl:copy-of select="@"/> </xsl:element> </xsl:template> I did look a bit at 1.1 but I was unsure as to it's completeness and whether it was fully implemented in the EE version. We are currently using the HE version for .net because I found myself bumping up against the limits of XPath in a rules processing app that takes this data format as input. Thanks for the help, maybe I will have to pick up the EE version and try out the new features.

    (1-2/2)

    Please register to reply