This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Microsoft XML > March 2005 > Can an XSD specify a "free form" node?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Can an XSD specify a "free form" node?
Steve

2005-03-21, 6:57 pm

Hello. I new to creating XSD's, but I want to create a schema which lets one
node be explicitly defined, but also have other nodes can be anything. Below
is an example schema which I created in XMLSpy. See the comment in the
middle which will hopefully make my question more clear!

My ultimate goal is this: I want to bind an XML field in Sql Server 2005
with a schema, but not always be that exact schema. (make sense? One might
say this contradicts the definition of a schema)


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="TheRoot">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="MustHaveNode">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<!---******How can I tell an XSD that that there can be another node that is
called anything with any types of descendants?? I.e. a "Free form" node.
*****-->
<xs:element name="CanBeAnythingNode">
<xs:complexType>
<xs:sequence>
<xs:element name="BlahBlah1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
--
Steve
Martin Honnen

2005-03-21, 6:57 pm



Steve wrote:

> I new to creating XSD's, but I want to create a schema which lets one
> node be explicitly defined, but also have other nodes can be anything.


You can use the xs:any element inside your schema, see
<http://www.w3.org/TR/xmlschema-1/#Wildcards>
for the definition and
<http://www.w3.org/TR/xmlschema-0/#any>
for examples.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews