Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > restrictions for attributes

Reply
Thread Tools

restrictions for attributes

 
 
ruthless@poczta.onet.pl
Guest
Posts: n/a
 
      12-07-2003
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">
<xsattern 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



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.542 / Virus Database: 336 - Release Date: 03-11-18


 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      12-07-2003


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> 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">
> <xsattern 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">
<xsattern value="yes|no" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
 
ruthless@poczta.onet.pl
Guest
Posts: n/a
 
      12-07-2003
thnx - it's working

greetings R

Uzytkownik "Martin Honnen" <(E-Mail Removed)> napisal w wiadomosci
news:3fd36c86$(E-Mail Removed)...
>
>
> (E-Mail Removed) wrote:
>
> > 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">
> > <xsattern 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">
> <xsattern value="yes|no" />
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> </xs:complexType>
> </xs:element>
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.542 / Virus Database: 336 - Release Date: 03-11-18


 
Reply With Quote
 
Mike Rawlins
Guest
Posts: n/a
 
      12-10-2003
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.
--
Michael C. Rawlins, Rawlins EC Consulting
www.rawlinsecconsulting.com
Using XML with Legacy Business Applications (Addison-Wesley, 2003)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
schema, attributes, interdependent restrictions Marc Hebert XML 3 05-24-2008 04:40 PM
Applying Restrictions to XML Attributes mnickel67@gmail.com XML 4 02-01-2008 06:59 PM
WebControl.Attributes.Add and custom attributes P4trykx ASP .Net 2 01-31-2007 04:33 PM
Parse reserved attributes as normal attributes Max XML 1 09-22-2006 12:04 PM
[NEWBIE] Restrictions on attributes poematrix XML 2 09-07-2004 10:30 AM



Advertisments