473,320 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

simple and complex unions?

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 <valuenode:

<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
Jan 7 '08 #1
3 1548
st***********@yahoo.com 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 <valuenode:

<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</valuebut as well <value><object>foo</object>1234</value>:
<URL:http://www.w3.org/TR/xmlschema-0/#mixedContent>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 7 '08 #2
On Jan 7, 3:08 am, Martin Honnen <mahotr...@yahoo.dewrote:
stevecanfi...@yahoo.com 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 <valuenode:
<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</valuebut 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
Jan 7 '08 #3
On 7 Jan, 19:36, "stevecanfi...@yahoo.com" <stevecanfi...@yahoo.com>
wrote:
On Jan 7, 3:08 am, Martin Honnen <mahotr...@yahoo.dewrote:
stevecanfi...@yahoo.com 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 <valuenode:
* * <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</valuebut 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
Jan 8 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mjcsfo | last post by:
I can't seem to find a reference nor any helpful threads on this topic. I've gotten the following error in two circumstances: 1. A complex type has nested within it another complex type, in the...
15
by: David | last post by:
Some developers in my group are using UNIONS to define their data types in a C++ program for an embedded system. Are there any pro and cons in doing this when you can define a CLASS to do the same...
6
by: Neil Zanella | last post by:
Hello, I would like to know whether the following C fragment is legal in standard C and behaves as intended under conforming implementations... union foo { char c; double d; };
16
by: Tim Cambrant | last post by:
Hi. I was reading up a bit on the features of C I seldom use, and I came across unions. I understand the concept, and that all the contained variables etc. share the same memory. Thus, when a new...
23
by: rohit | last post by:
Hi, In my couple of years of experience, I have never found a single instance where I needed to use unions and bitfields(though I have used structures).I was just imagining where would these find...
13
by: Mike S | last post by:
I came across the following paragraph in the "Semantics" section for simple assignment in N1124 (C99 draft) and I'm wondering if I'm interpreting it right: 6.5.16.1p3: If the value being...
4
by: uralmutlu | last post by:
Hi, I was wandering if I can have classes in unions? I basically have source code in a format very similar to: union example { ClassA variable1; ClassB variable2; };
67
by: bluejack | last post by:
A recent post asking for help with unions reminded me of this component of the C language that I have only used a couple of times, and those almost entirely out of personal whim -- Unions for the...
11
by: pereges | last post by:
Hello, can some one please guide me a little into using unions. I read about unions in K & R but I am finding it difficult to apply to my problem at hand. I want to save up some space by using...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.