Page 1 of 1

Specify the value for an element that references several att

Posted: Tue Sep 13, 2005 10:30 pm
by MonteInca
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

Posted: Wed Sep 14, 2005 9:15 am
by george
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