If you don't care about the order in which colors appear, you can do this in
xml schema. Depending on how complex your schema is, you might be able to
to something like this for more than just one level.
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="foo"
elementFormDefault="qualified"
xmlns="foo"
xmlns:foo="foo"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="colorType">
<xs:restriction base="xs:string">
<xs:enumeration value="green"/>
<xs:enumeration value="red"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="colors">
<xs:complexType>
<xs:sequence>
<xs:element name="color" type="colorType" minOccurs="2"
maxOccurs="2"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="uniqueColors">
<xs:selector xpath="foo:color"/>
<xs:field xpath="."/>
</xs:unique>
</xs:element>
</xs:schema>
--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
<mh******@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I am using XML Schema for quite a while but haven't written a single
line of Relax NG yet.
For what I know, I cannot define static content within an XML Schema.
For example, I have the following structure:
<colors>
<color>green</color>
<color>red</color>
</colors>
With XML-Schema, I can say colors should have to elements of type
color, and color can contain "green" or "red". But I cannot say that
the content has to be exactly as posted above. Is this correct?
Is there a way to do this in Relax NG?
I need it for more levels than just one. I want to be able to define a
whole XML-Document within the "Schema", so only a document with exactly
that content will be valid.