-
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 ------------------------------------
-
<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
-
By rperez in forum Database
Replies: 5
Last Post: 01-02-2009, 04:14 PM
-
By Becky in forum Database
Replies: 1
Last Post: 07-11-2000, 03:27 PM
-
By D. Patrick Hoerter in forum Database
Replies: 1
Last Post: 06-26-2000, 04:57 PM
-
By Devaraj in forum Enterprise
Replies: 0
Last Post: 05-11-2000, 12: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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks