Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Element restriction when I have elements 1

Status
Not open for further replies.

chrish22

Programmer
Apr 30, 2008
4
GB
Hi all

I'm sure this is a noob question and will be simple for you experts to answer here goes.

Why can I not restrict an element when it has attributes for example....

<xs:element minOccurs="0" maxOccurs="unbounded" name="Forename">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Member" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>

I would want to restrict the length of the Name element to 30 characters.

I know a workaround is to define a new type, but if I only use this once in my schema surely this is inefficient??

Thanks in advance.

Chris.
 
I think I understand what is the concern. "Workaround" is just a word, it has many connotations, I think, you want to convey mainly a "negative" sentiment. What if it is the proper way to do thing?

It is conceivable that in some other schema spec closely similar to wxsl that such a provision were allowed! but that's quite hypothetical. At for now, one cannot restrict and extend a type at the same time (ie, in a single type construction.)

As to efficiency/inefficiency, it is again often full of connotations. Suffice to recall that all built-in types are through restriction and extension at multiple time (rather than at the same time) of anyType? So it may be said efficient as well as inefficient to one's caprice.

The thing only remaining in the real at the present stage is that you have to do it through an intermediate type (which can be made abstract to stop its usage in any instance document).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top