In XSD, how can I make the elements occur in freewill order? (Tested in SQL 2005 Expr


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: In XSD, how can I make the elements occur in freewill order? (Tested in SQL 2005 Expr

  1. #1
    Join Date
    Aug 2005
    Posts
    37

    In XSD, how can I make the elements occur in freewill order? (Tested in SQL 2005 Expr

    In XSD, how can I make the elements occur in freewill order? (Tested in SQL 2005 Express Edition)


    I know if I add the keyword "sequence" in a XSD, the "Title" element must occur before "Url" element in XML. (Section A)

    now I hope "Title" and "Url" elements may occur in freewill order, that mean the following two codes are OK!

    Title="aa"
    Url=="bb"

    or

    Url=="bb"
    Title="aa"



    I try to write the xsd just like Section B (I think the keyword "group" will be effectually), but I get the error information below 沁SQL 2005!

    .Net SqlClient Data Provider: Msg 2299, Level 16, State 1, Line 1
    Missing attribute 'ref'


    Why? In XSD, how can I make the elements occur in freewill order? thanks





    //-----------------------------Section A ------------------------------------
    CREATE XML SCHEMA COLLECTION [dbo].[w1]
    AS N'

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.hellocw.com/onlinebookmark"
    targetNamespace="http://www.hellocw.com/onlinebookmark"
    elementFormDefault="qualified">

    <xsd:element name="Folder" type="bookmarkType"/>

    <xsd:complexType name="bookmarkType">

    <xsd:sequence>
    <xsd:element name="Title" type="xsd:string" />
    <xsd:element name="Url" type="xsd:string" />
    </xsd:sequence>

    </xsd:complexType>

    </xsd:schema>

    '
    GO
    //-----------------------------Section A ------------------------------------





    //-----------------------------Section B ------------------------------------
    CREATE XML SCHEMA COLLECTION [dbo].[w2]
    AS N'

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.hellocw.com/onlinebookmark"
    targetNamespace="http://www.hellocw.com/onlinebookmark"
    elementFormDefault="qualified">

    <xsd:element name="Folder" type="bookmarkType"/>

    <xsd:complexType name="bookmarkType">

    <xsd:group>
    <xsd:element name="Title" type="xsd:string" />
    <xsd:element name="Url" type="xsd:string" />
    </xsd:group>

    </xsd:complexType>


    </xsd:schema>

    '
    GO
    //-----------------------------Section B ------------------------------------

  2. #2
    Join Date
    Aug 2005
    Posts
    23
    <xsd:group/> is not designed to be used as you are trying.
    you declare the <xsd:group name="yourGroup">... just under documentElement.
    then within a complexType you would put:
    choice, all, or sequence --> then <group ref="yourGroup" minOccurs="0" maxOccurs="unbounded"/>

    <xsd:all> allows free flow, but only 0 or 1 occurances;
    <xsd:choice min 0 max unbounded> will give you a freeflow, but you will not be able to set any restraints on howMany, or sequence.

    bit complicated, but sacrifices must be made for regidity.

Similar Threads

  1. find version & service packs
    By rperez in forum Database
    Replies: 5
    Last Post: 01-02-2009, 05:14 PM
  2. SQL server administrative knowledge
    By Becky in forum Database
    Replies: 1
    Last Post: 07-11-2000, 04:27 PM
  3. Re: Sort problem in MS SQL Server 7.0
    By D. Patrick Hoerter in forum Database
    Replies: 1
    Last Post: 06-26-2000, 05:57 PM
  4. Re: ODBC error
    By Devaraj in forum Enterprise
    Replies: 0
    Last Post: 05-11-2000, 01:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center