Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > complex type schema

Reply
Thread Tools

complex type schema

 
 
motorpage@gmail.com
Guest
Posts: n/a
 
      10-22-2007
Hi,

I am a newbie to schema definitions so forgive me if this is a simple
question.

I am trying to create a schema for a complex type that allows
instances of either of the two forms:

<test1 state=true>
<name>test1/>
<type>typeA/>
</test1>

<test2 state=false>
<name>test2/>
<type>type@/>
</test2>

Here the 'type' element is a string without the '@' character if
'state' is true and a string with the '@' character when state is
false.

 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      10-22-2007
wrote:
> I am trying to create a schema for a complex type that allows
> instances of either of the two forms:
>
> <test1 state=true>
> <name>test1/>
> <type>typeA/>
> </test1>
>
> <test2 state=false>
> <name>test2/>
> <type>type@/>
> </test2>


XML Schemas don't allow you to select between two different types of
content based on the value of a variable -- *EXCEPT* by making the two
types of content subtypes of a single type, and then using the xsi:type
attribute to switch between them. If you are willing to replace your
"state" with that directive, you can make this work. Otherwise, do this
cross-dependency check in your application code, or investigate whether
your environment supports any of the other schema languages.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
 
jasonturner76@googlemail.com
Guest
Posts: n/a
 
      10-23-2007
I'm just starting to get my head around XML Schemas. I found XML
Studio really good for learning the basics, and its free

http://www.liquid-technologies.com/P...XmlStudio.aspx

Regards Jason

On 22 Oct, 19:40, motorp...@gmail.com wrote:
> Hi,
>
> I am a newbie to schema definitions so forgive me if this is a simple
> question.
>
> I am trying to create a schema for a complex type that allows
> instances of either of the two forms:
>
> <test1 state=true>
> <name>test1/>
> <type>typeA/>
> </test1>
>
> <test2 state=false>
> <name>test2/>
> <type>type@/>
> </test2>
>
> Here the 'type' element is a string without the '@' character if
> 'state' is true and a string with the '@' character when state is
> false.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wsdl2java: method parameter a complex type that extends another complex type Robert Mark Bram Java 0 02-04-2007 10:06 AM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Newbie problem?: XML-Schema Instance Validation (xerces 2.6.0, confusingcvc-complex-type errors) Grand Apeiron XML 7 01-20-2004 12:04 AM
XML Schema Q: Preventing an empty element of a complex type Rich Weed XML 0 07-16-2003 12:50 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57