473,320 Members | 1,744 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.

Option between simple OR complex types in an XML Schema?

Let's say I have an element that can contain a simple child element, OR
a child element of complex type (but not both). For example, an actual
XML snippet might look like this...

<ValueMapping>
<LocalValue>abc123</LocalValue>
<RemoteValue>123abc</RemoteValue>
</ValueMapping>

....or the XML might look like this...

<ValueMapping>
<LocalValue>abc123</LocalValue>
<MultiValueList>
<RemoteValue>123</RemoteValue>
<RemoteValue>abc</RemoteValue>
</MultiValueList>
</ValueMapping>
Is there an XML Schema I could write that would support both of these
possibilies... allowing the "RemoteValue" to be either a simple element
or a complex type of multiple elements (but not both at the same time)?
Thanks in advance!
Jun 14 '07 #1
1 1266
Steve wrote:
Let's say I have an element that can contain a simple child element, OR
a child element of complex type (but not both). For example, an actual
XML snippet might look like this...

<ValueMapping>
<LocalValue>abc123</LocalValue>
<RemoteValue>123abc</RemoteValue>
</ValueMapping>

...or the XML might look like this...

<ValueMapping>
<LocalValue>abc123</LocalValue>
<MultiValueList>
<RemoteValue>123</RemoteValue>
<RemoteValue>abc</RemoteValue>
</MultiValueList>
</ValueMapping>
Is there an XML Schema I could write that would support both of these
possibilies... allowing the "RemoteValue" to be either a simple element
or a complex type of multiple elements (but not both at the same time)?
You can use xs:choice likt this:

<xs:element name="ValueMapping">
<xs:complexType>
<xs:sequence>
<xs:element name="LocalValue" type="xs:string"/>
<xs:choice>
<xs:element name="RemoteValue" type="xs:string"/>
<xs:element name="MultiValueList">
<xs:complexType>
<xs:sequence>
<xs:element name="RemoteValue" type="xs:string"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:complexType>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 14 '07 #2

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

Similar topics

2
by: burdeen | last post by:
I've been trying to return an array with PHP5 soap. Is this not supported? or am i doing it wrong? Seems to return on the last element in the array. In my WSDL i've defined my return type as a...
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...
0
by: AL | last post by:
Hello, working on an xsd schema, I'd like it to have a node of which I don't know the content at design time: I want the document instance to identify such node contents, where content should have...
4
by: scorpion | last post by:
I have a simple type like this: <xs:simpleType name="SizeType"> <xs:restriction base="xs:token"> <xs:enumeration value="small"/> <xs:enumeration value="medium"/> <xs:enumeration...
1
by: Volker Zink | last post by:
I am writing my first schema and have 3 complex types which represent "top level objects": <complex type name="A1"> .... </complex type> <complex type name="A2"> .... </complex type>
2
by: brian.gabriel | last post by:
I am having difficulty coming up with an elegant solution to a problem that I am having. I have a web service that processes different types of requests and return the appropriate response. Each...
3
by: Chris Lieb | last post by:
I am new to XML Schema and am running into a bit of a snag. I have defined an XML-based scripting language for an updater program that I am working on. I would like to make a schema for this...
3
by: andreas.baus | last post by:
Hello. I'm trying to exchange data between a webservice based on Apache Axis and a client written in C#, and so far it has been working with few problems (none that I couldn't solve myself with...
3
by: katis | last post by:
Hi all :) Is it posible in xsd to change only minOccurs value of element in complex type by extending this type? The problem I'm trying to solve is this: I have two complex types -...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.