Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xsd Xml Schema - Same Element With Different Properties 1

Status
Not open for further replies.

myghty

Programmer
Aug 5, 2006
2
SI
Hi!

I am writing an xml schema and i came to an problem. I want to have
element "protocol" 2 times but each time with different properties. It also has
an element access also each time different properties.
I have tried the choice option but my validation tool says that a cant use the same element. Is it possible to solve this in an different way?

<xs:choice>
<xs:element name="protocol">
<xs:complexType>
<xs:sequence>
<xs:element name="type" type="xs:string" />
<xs:element name="version" type="xs:string" />
<xs:element name="timeout" type="xs:integer" />
<xs:element name="access" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="security_level" type="xs:string" />
<xs:element name="user_security_name" type="xs:string" />
<xs:element name="user_context_name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="protocol">
<xs:complexType>
<xs:sequence>
<xs:element name="type" type="xs:string" />
<xs:element name="access" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="community" type="xs:string" />
<xs:element name="set_community" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>



Is it possible to solve this? Please help.

 
Short answer is: not possible in the framework of W3C XML Schema Language.

A workaround may be possible for this particular case (not generally). You may take a look of my previous post.
But it involves a material change of the source document.

Might have to consider to use in tandem with alternative languages as Schematron.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top