Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > simple and complex unions?

Reply
Thread Tools

simple and complex unions?

 
 
stevecanfield@yahoo.com
Guest
Posts: n/a
 
      01-07-2008
I have xml that has nodes that either have a text value or more nested
elements. For example, both of these are valid for my <value> node:

<value>1234</value>
and
<value><object>foo</object></value>

Any clues on how I could express this in the schema (xsd)? I've
figured out how to do one or the other, but not allow either. It seems
like it should be very simple, but I'm stuck... Please help!

-sc
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-07-2008
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I have xml that has nodes that either have a text value or more nested
> elements. For example, both of these are valid for my <value> node:
>
> <value>1234</value>
> and
> <value><object>foo</object></value>
>
> Any clues on how I could express this in the schema (xsd)? I've
> figured out how to do one or the other, but not allow either. It seems
> like it should be very simple, but I'm stuck... Please help!


I think you need to allow mixed contents theN which would not only allow
<value>1234</value> but as well <value><object>foo</object>1234</value>:
<URL:http://www.w3.org/TR/xmlschema-0/#mixedContent>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
stevecanfield@yahoo.com
Guest
Posts: n/a
 
      01-07-2008
On Jan 7, 3:08 am, Martin Honnen <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > I have xml that has nodes that either have a text value or more nested
> > elements. For example, both of these are valid for my <value> node:

>
> > <value>1234</value>
> > and
> > <value><object>foo</object></value>

>
> > Any clues on how I could express this in the schema (xsd)? I've
> > figured out how to do one or the other, but not allow either. It seems
> > like it should be verysimple, but I'm stuck... Please help!

>
> I think you need to allow mixed contents theN which would not only allow
> <value>1234</value> but as well <value><object>foo</object>1234</value>:
> <URL:http://www.w3.org/TR/xmlschema-0/#mixedContent>


I ended up doing just that, but I'm not entirely happy with the
result. It seems to me that specifying mixed content allows *any* text
content. I'd like to limit it to just digits.

-sc
 
Reply With Quote
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      01-08-2008
On 7 Jan, 19:36, "(E-Mail Removed)" <(E-Mail Removed)>
wrote:
> On Jan 7, 3:08 am, Martin Honnen <(E-Mail Removed)> wrote:
>
> > (E-Mail Removed) wrote:
> > > I have xml that has nodes that either have a text value or more nested
> > > elements. For example, both of these are valid for my <value> node:

>
> > > * * <value>1234</value>
> > > and
> > > * * <value><object>foo</object></value>

>
> > > Any clues on how I could express this in the schema (xsd)? I've
> > > figured out how to do one or the other, but not allow either. It seems
> > > like it should be verysimple, but I'm stuck... Please help!

>
> > I think you need to allow mixed contents theN which would not only allow
> > <value>1234</value> but as well <value><object>foo</object>1234</value>:
> > <URL:http://www.w3.org/TR/xmlschema-0/#mixedContent>

>
> I ended up doing just that, but I'm not entirely happy with the
> result. It seems to me that specifying mixed content allows *any* text
> content. I'd like to limit it to just digits.
>
> -sc


Alas, with XSD, using the mixed content is the best you can do. It
would be nice if XSD had something like xs:text similar to what Relax-
NG has so you could do:

<xs:complexType ...>
<xs:choce>
<xs:text type='xs:int'/>
<xs:element name='object' type='xs:string'/>
</xs:choice>
</xs:complexType>

Unfortunately it's not even on the radar for the next version of XSD.

HTH,

Pete Cordell
Codalogic
Visit http://www.codalogic.com/lmx/ for XML C++ data binding
 
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
How complex is complex? Kottiyath Python 22 03-28-2009 10:11 PM
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
For expert on complex loops (reposted) - complex looping problem news.amnet.net.au Java 1 04-13-2004 07:10 AM
Problem with local complex or simple types in Apache Axis mjcsfo Java 0 08-14-2003 03:53 PM



Advertisments