This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > August 2004 > XSD and specifying attribute list





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author XSD and specifying attribute list
Don

2004-08-30, 11:16 pm

Hi:

I know it is possible to specify what elements can exist under an element.
Is it possible to define what string values can be entered for a particular
attribute?

Thanks,

Do


Zafar Abbas [MSFT]

2004-08-30, 11:16 pm

Yes, if you want constrain the content of an attribute to a few values you
can use the xs:enumeration facet on the simple type you define for the
attribute. The following example ONLY allows stirng values "a" "b" and "c"
for the attribute "attr".

<xsd:element name="doc">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="child1" type="xsd:string"/>
<xsd:element name="child2" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="attr">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="a" />
<xsd:enumeration value="b" />
<xsd:enumeration value="c" />
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>

"Don" <doduong12141214@hotmail.com> wrote in message
news:eBtV13ujEHA.728@TK2MSFTNGP09.phx.gbl...
> Hi:
>
> I know it is possible to specify what elements can exist under an

element.
> Is it possible to define what string values can be entered for a

particular
> attribute?
>
> Thanks,
>
> Do
>
>



Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews