By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 1,062 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

Defining a type or element for this element/complex data type ...

P: n/a
Hi

<ClubNight Name = "Go club" Date = "2006-09-09">
Discussed a few simple proverbs.
<Attendee Name = "RJ"/>
<Attendee Name = "TT"/>
<Attendee Name = "RB"/>
</ClubNight>

I'm trying to work out if I can actually define this as a complex type
in my schema.

I can do it no problems without the text 'Discussed a few simple
proverbs." but no matter how I fiddle with extending a simple type and
so on, I just can't get it working.

Is it actually possible? Thanks for any advice.

Emma

Sep 9 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<em**************@fastmail.fmwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hi

<ClubNight Name = "Go club" Date = "2006-09-09">
Discussed a few simple proverbs.
<Attendee Name = "RJ"/>
<Attendee Name = "TT"/>
<Attendee Name = "RB"/>
</ClubNight>

I'm trying to work out if I can actually define this as a complex type
in my schema.

I can do it no problems without the text 'Discussed a few simple
proverbs." but no matter how I fiddle with extending a simple type and
so on, I just can't get it working.

Is it actually possible? Thanks for any advice.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="ClubNight">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Attendee"/>
</xs:sequence>
<xs:attribute name="Date" use="required" type="xs:NMTOKEN"/>
<xs:attribute name="Name" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="Attendee">
<xs:complexType>
<xs:attribute name="Name" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
</xs:schema>

Emma, to give credit where it's due, this was generated by Stylus Studio
(http://www.stylusstudio.com/).

John

BTW, if you have a choice, I'd put the text in an element, like:

<NotesDiscussed a few simple proverbs.</Notes>

This would allow for greater flexibility later on. You could, for instance,
structure the notes, or include XHTML in them.
Sep 9 '06 #2

P: n/a
John Saunders wrote:
<em**************@fastmail.fmwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hi

<ClubNight Name = "Go club" Date = "2006-09-09">
Discussed a few simple proverbs.
<Attendee Name = "RJ"/>
<Attendee Name = "TT"/>
<Attendee Name = "RB"/>
</ClubNight>

I'm trying to work out if I can actually define this as a complex type
in my schema.

I can do it no problems without the text 'Discussed a few simple
proverbs." but no matter how I fiddle with extending a simple type and
so on, I just can't get it working.

Is it actually possible? Thanks for any advice.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="ClubNight">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Attendee"/>
</xs:sequence>
<xs:attribute name="Date" use="required" type="xs:NMTOKEN"/>
<xs:attribute name="Name" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="Attendee">
<xs:complexType>
<xs:attribute name="Name" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
</xs:schema>

Emma, to give credit where it's due, this was generated by Stylus Studio
(http://www.stylusstudio.com/).

John

BTW, if you have a choice, I'd put the text in an element, like:

<NotesDiscussed a few simple proverbs.</Notes>

This would allow for greater flexibility later on. You could, for instance,
structure the notes, or include XHTML in them.
Hi

Thanks for the reply. The thing with <xs:complexType mixed="true"is
that it also validates when 'text' is sandwiched between the direct
descendent elements too! Ah well - I doubt if there's a way to
constrain that. I agree with your comment about having a proper <Notes>
element. I was thinking it is really more of an attribute of
<ClubNightbut then that approach seems to have the same drawbacks as
having it as text. As you say, the <Noteselement can then be extended
without breaking the definition of ClubNight.

Thanks!

Emma

Sep 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.