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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a xs:complexType contain references to itself??? I'm new to Schema

Status
Not open for further replies.

Urieal

Programmer
Jan 29, 2009
3
I am trying to write a schema with some basic types.

See the following:


<xs:complexType name="Paragraph">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="myattribute" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>

I would like this "Paragraph" type to have any number of child paragraphs
ie...the XML would look something like this
<paragraph myattribute="abc">
this is my text and i like it
<paragraph myattribute="efg">
this is some more of my text
</paragraph>
</paragraph>

basically I need the paragraph to be able to hold 0 to unbounded # child paragraphs...

how do I accomplish this?
 
I believe I may have come up with the solution...

would this work?

<xs:complexType name="paragraph" mixed="true">
<xs:sequence>
<xs:element name="subparagraph" type="paragraph" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="myattrib" type="xs:string"/>
</xs:complexType>
 
I just checked an XML vs this schema...it works! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top