I've tried the search function and get no usable results. So, sorry if this is a noobie question.... it may very well be. I'm a noob to playing with this stuff.
I am trying to write a schema that will enforce the content (value) of two elements that have the same name.
For instance, if the XML looked like:
I'd use a schema that looked like:
However, the XML needs to have two 'color' elements one containing 'blue' and the second containing 'red'. This is a very small part of a much nastier schema.
I'd like to be able to use two different types for the 'color' element, like:
How do a control the content of the sequential 'color' elements so that the first contains 'blue' and the second contains 'red'? Apparently, it is illegal to use two different 'types' for the same element name. Help?
Thanks a ton.
'hope this helps
If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
I am trying to write a schema that will enforce the content (value) of two elements that have the same name.
For instance, if the XML looked like:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<root_element
xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL]
xsi:noNamespaceSchemaLocation="example.xsd">
<registrant>
<color>blue</color>
<color>blue</color>
</registrant>
</root_element>
I'd use a schema that looked like:
Code:
<?xml version="1.0"?>
<xsd:schema
xmlns="[URL unfurl="true"]http://www.csc.noaa.gov/ioos/schema"[/URL]
xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL]
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xsd:element name="root_element">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="registrant">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="color">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="blue"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="color"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
However, the XML needs to have two 'color' elements one containing 'blue' and the second containing 'red'. This is a very small part of a much nastier schema.
I'd like to be able to use two different types for the 'color' element, like:
Code:
<?xml version="1.0"?>
<xsd:schema
xmlns="[URL unfurl="true"]http://www.csc.noaa.gov/ioos/schema"[/URL]
xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL]
elementFormDefault="qualified"
attributeFormDefault="qualified">
<xsd:element name="root_element">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="registrant">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="color">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="blue"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:element name="color">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="red"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
How do a control the content of the sequential 'color' elements so that the first contains 'blue' and the second contains 'red'? Apparently, it is illegal to use two different 'types' for the same element name. Help?
Thanks a ton.
'hope this helps
If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.