Specify the value for an element that references several att

This should cover W3C XML Schema, Relax NG and DTD related problems.
MonteInca
Posts: 1
Joined: Tue Sep 13, 2005 10:22 pm

Specify the value for an element that references several att

Post by MonteInca » Tue Sep 13, 2005 10:30 pm

Hello to everyone. Thanks for reading this.

Im working with XML Schema to specify graphs. In the graph we have nodes, and each node can have several attribute (with a key and value), but I want to force the user to always add one attribute with a specific key and three posible values… ¿Is this possible in XML SCHEMA without defining a new type or element…


This is the XML SCHEMA for the attribute
<!-- Global Attributes -->
<xsd:attributeGroup name="global-atts">
<xsd:attribute name="id" type="string.type" />
<xsd:attribute name="name" type="string.type" />
<xsd:attribute name="label" type="string.type" />
</xsd:attributeGroup>

<!-- Value Attribute -->
<xsd:attributeGroup name="attribute-value">
<xsd:attribute name="value" type="string.type" />
</xsd:attributeGroup>

<!-- Type Attribute -->
<xsd:attributeGroup name="attribute-type">
<xsd:attribute name="type" type="object.type" />
</xsd:attributeGroup>

<!-- Att Element -->
<xsd:element name="att">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:element ref="att" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attributeGroup ref="global-atts" />
<xsd:attributeGroup ref="attribute-value" />
<xsd:attributeGroup ref="attribute-type" />
</xsd:complexType>
</xsd:element>

And this for the node…
<!-- Simple Node (Structural Node) -->
<xsd:complexType name="simpleNode">
<xsd:sequence>
<xsd:element ref="att" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attributeGroup ref="global-atts" />
</xsd:complexType>

And i want all node to be like this…
<node ...>
<att name=”Status” value=””> THIS ALWAYS HAVE TO BE WITH THAT NAME.
<att…
<att…
</node>

Thanxs for all

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Wed Sep 14, 2005 9:15 am

Hi,

No, you cannot do that in XML Schema. There are a couple of options further, use XML Schema with embedded Schematron rules, use Relax NG or use Schematron. All these options are supported by oXygen.

Best Regards,
George

Post Reply