A
Adam dR.
I am not sure if it is possible to create a schema to do what I want.
I would like the element <package-element> to have a different schema
based on the value of it's handler attribute.
This is my XML:
<package-suite>
<timsdata-package name="System Defined Note Categories"
version="32.150">
<package-element handler="db-table-handler">
<table>notecategory</table>
<data>Refund</data>
</package-element>
</timsdata-package>
<timsdata-package name="identifiers" version="33.012">
<package-element handler="identifier-handler">
<file>exe:ident.tbl</file>
</package-element>
</timsdata-package>
</package-suite>
notice the child tags of package-element are different depending on
the value of the handler attribute. Is it possible to do this?
Here was my shot at the XSD file: ( This is invalid because the
timsdata-packagetype defines <xs:element name="package-element"...
twice. This is what I want though. Is there another way to
accomplish this.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="db-table-handler-type">
<xs:sequence>
<xs:element name="table" type="xs:string"/>
<xs:element name="data" type="xs:string"/>
</xs:sequence>
<xs:attribute name="handler" type="xs:string" use="required"
fixed="db-table-handler"/>
</xs:complexType>
<xs:complexType name="identity-handler-type">
<xs:sequence>
<xs:element name="file" type="xs:string"/>
</xs:sequence>
<xs:attribute name="handler" type="xs:string" use="required"
fixed="identity-handler"/>
</xs:complexType>
<xs:element name="package-suite">
<xs:complexType>
<xs:sequence>
<xs:element name="timsdata-package" type="timsdata-packageType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="timsdata-packageType">
<xs:sequence>
<xs:element name="package-element" type="db-table-handler-type"/>
<xs:element name="package-element" type="identity-handler-type"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:decimal" use="required"/>
</xs:complexType>
</xs:schema>
A reference or any help would be appreciated, thanks.
I would like the element <package-element> to have a different schema
based on the value of it's handler attribute.
This is my XML:
<package-suite>
<timsdata-package name="System Defined Note Categories"
version="32.150">
<package-element handler="db-table-handler">
<table>notecategory</table>
<data>Refund</data>
</package-element>
</timsdata-package>
<timsdata-package name="identifiers" version="33.012">
<package-element handler="identifier-handler">
<file>exe:ident.tbl</file>
</package-element>
</timsdata-package>
</package-suite>
notice the child tags of package-element are different depending on
the value of the handler attribute. Is it possible to do this?
Here was my shot at the XSD file: ( This is invalid because the
timsdata-packagetype defines <xs:element name="package-element"...
twice. This is what I want though. Is there another way to
accomplish this.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="db-table-handler-type">
<xs:sequence>
<xs:element name="table" type="xs:string"/>
<xs:element name="data" type="xs:string"/>
</xs:sequence>
<xs:attribute name="handler" type="xs:string" use="required"
fixed="db-table-handler"/>
</xs:complexType>
<xs:complexType name="identity-handler-type">
<xs:sequence>
<xs:element name="file" type="xs:string"/>
</xs:sequence>
<xs:attribute name="handler" type="xs:string" use="required"
fixed="identity-handler"/>
</xs:complexType>
<xs:element name="package-suite">
<xs:complexType>
<xs:sequence>
<xs:element name="timsdata-package" type="timsdata-packageType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="timsdata-packageType">
<xs:sequence>
<xs:element name="package-element" type="db-table-handler-type"/>
<xs:element name="package-element" type="identity-handler-type"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="version" type="xs:decimal" use="required"/>
</xs:complexType>
</xs:schema>
A reference or any help would be appreciated, thanks.