restrictions for attributes

Ruthless (2)

Usenet Archive
Joined
Nov 29, 2003
Messages
3
Reaction score
0
hello.

I've got a problem - can I do any restrictions for my attributes?

I found how to restrict elements and was trying to use them with my attributes

e.g. <person sex="F"> sex can be anly F and M

i've got sth like this:

<xs:complexType name="person-type">
[...]
<xs:attribute name="sex">
<xs:restriction base="xs:string">
<xs:pattern value="F|M"/>
</xs:restriction>
</xs:attribute>
</xs:complexType>

when I valid it using: http://www.w3.org/2001/03/webdata/xsv i recieve info:

* The schema(s) used for schema-validation had no errors

so my scheme is correct or not?
I recieve errors while i'm validating xml + xsd, xsd itself is valid(see above)

xml is correct i have only change my xsd file with the sex attribute without sex restrictions it was OK

thnx in advance
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
I've got a problem - can I do any restrictions for my attributes?

I found how to restrict elements and was trying to use them with my attributes

e.g. <person sex="F"> sex can be anly F and M

i've got sth like this:

<xs:complexType name="person-type">
[...]
<xs:attribute name="sex">
<xs:restriction base="xs:string">
<xs:pattern value="F|M"/>
</xs:restriction>
</xs:attribute>
</xs:complexType>

when I valid it using: http://www.w3.org/2001/03/webdata/xsv i recieve info:

* The schema(s) used for schema-validation had no errors

so my scheme is correct or not?
I recieve errors while i'm validating xml + xsd, xsd itself is valid(see above)

xml is correct i have only change my xsd file with the sex attribute without sex restrictions it was OK

You need to restrict a simple type as in

<xs:element name="root">
<xs:complexType>
<xs:attribute name="att" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="yes|no" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
 

Ruthless (2)

Usenet Archive
Joined
Nov 29, 2003
Messages
3
Reaction score
0
thnx - it's working

greetings R

Uzytkownik "Martin Honnen said:
I've got a problem - can I do any restrictions for my attributes?

I found how to restrict elements and was trying to use them with my attributes

e.g. <person sex="F"> sex can be anly F and M

i've got sth like this:

<xs:complexType name="person-type">
[...]
<xs:attribute name="sex">
<xs:restriction base="xs:string">
<xs:pattern value="F|M"/>
</xs:restriction>
</xs:attribute>
</xs:complexType>

when I valid it using: http://www.w3.org/2001/03/webdata/xsv i recieve info:

* The schema(s) used for schema-validation had no errors

so my scheme is correct or not?
I recieve errors while i'm validating xml + xsd, xsd itself is valid(see above)

xml is correct i have only change my xsd file with the sex attribute without sex restrictions it was OK

You need to restrict a simple type as in

<xs:element name="root">
<xs:complexType>
<xs:attribute name="att" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="yes|no" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
 

Mike Rawlins

Usenet Archive
Joined
Dec 9, 2003
Messages
1
Reaction score
0
Off the top of my head that ought to work, though there may be something wrong in the regular express you use to specify the pattern. However, rather than trying to fix your pattern, the more conventional way to do what you want is to use the xs:enumeration element for each allowed value.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top