Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2007, 09:06 PM
Authorized User
 
Join Date: Jun 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conforming to a schema

Hi there,

Is it possible to a create a schema that allows an xml document to have repeating child nodes of a parent to be appearing in any order? For example, the following is a sample of my xml document.

<parent>
  <child1>A</child1>
  <child1>B</child1>
  <child2>C</child2>
  <child1>D</child1>
  <child3>E</child3>
  <child3>F</child3>
  <child2>G</child2>
</parent>

With my current schema as shown, the xml document obviouslt doesnt conforms to the schema. How can I change my schema document so that it will allow for any order and with the possiblity that the different child elements to be repeating?

<xs:element name="parent">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="child1" maxOccurs="unbounded"/>
                <xs:element ref="child2" maxOccurs="unbounded"/>
                <xs:element ref="child3" maxOccurs="unbounded"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

thanks



 
Old January 8th, 2007, 06:03 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Not exactly on-topic for an XSLT forum...

You can write

    <xs:element name="parent">
        <xs:complexType>
            <xs:choice maxOccurs="unbounded">
                <xs:element ref="child1" />
                <xs:element ref="child2" />
                <xs:element ref="child3" />
            </xs:choice>
        </xs:complexType>
    </xs:element>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Conforming to a schema Chamkaur XML 1 January 12th, 2007 04:26 AM
Getting schema for database Quick209 ASP.NET 2.0 Basics 0 December 12th, 2006 07:51 PM
Schema to Schema conversion onlyda XSLT 5 March 23rd, 2006 12:25 PM
Schema help!? beerni XML 3 October 14th, 2005 08:24 AM
Schema gabrieldg74 XML 0 August 16th, 2005 05:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.