473,386 Members | 1,715 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,386 software developers and data experts.

Nodes appears depending on a condition

Hi everyone,

First of all, excuses for my english.

I'm trying to build a XSD schema for this XML:

<root>
<error>0</error>
<result>
<result1></result1>
<result2></result2>
</result>
</root>

and another example

<root>
<error>1</error>
</root>

with this RESTRICTIONS:

· Node error appears always expecifying the error if there is an error
(value different to 0) or not (error equals to 0).
· Only if there is not error (node error = 0) node "result" appears.

Any idea?

(Schemas i've tried get "ambiguous error")

THANKS FOR YOUR HELP !!!


Nov 11 '05 #1
2 1149
Hi Oleg,

First of all ... thank u for your interest.

I think it's probably to find a "trick" to express this condition ...
something like:

<xs:element name="root">
<xs:complexType>
<xs:choice>
<xs:group ref="noError"></xs:group>
<xs:group ref="error"></xs:group>
</xs:choice>
</xs:complexType>
</xs:element>

<xs:group name="noError">
<xs:sequence>
<xs:element name="error" type="xs:unsignedByte" fixed="0"></xs:element>
<xs:element name="results">
<xs:complexType> ...... <xs:complexType>
</xs:element>
</xs:sequence>
</xs:group>

<xs:group name="error">
<xs:sequence>
<xs:element name="error" type="xs:unsignedByte"></xs:element>
</xs:sequence>
</xs:group>
This schema gets a "ambiguous error" due to "error" node.

I'm trying to find something similar to this to resolve my problem
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> escribió en el mensaje
news:eO**************@tk2msftngp13.phx.gbl...
Manresa wrote:
· Only if there is not error (node error = 0) node "result" appears.

Any idea?

Xml Schema unable to express co-occurence constraints like this one. Try
another schema language or redesign your XML.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
Hi Oleg,

I agreed with you ... but there is a problem. A applications sends to my
programs XMLs following this structure and it's not possible to change the
way they do. I have to build the schema for a documentation task of the
project.

Finally i think i will describe the constraint in a annotation node and go
on.

Thanks a lof for you interest
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> escribió en el mensaje
news:u5**************@tk2msftngp13.phx.gbl...
Manresa wrote:
I think it's probably to find a "trick" to express this condition ...
Yeah, you can do that trick, but that mekes your schema ambiguous. Why

don;t you instead to design you XML in a more simple, reasonable and structured way - either error or result elements may occur, but not together?
<results>
<error>2</error>
</results>

<results>
<result1>...</result1>
</results>
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #3

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

Similar topics

2
by: arvindsd | last post by:
Hi all, The code below gets me a list of all the nodes within the node object called xml_tags_root. NodeList nl = xml_tags_root.getChildNodes(); The length of nodelist I get is double the...
2
by: Henri Sivonen | last post by:
I try to associate DOM nodes with other objects. Assigning custom properties to DOM nodes works in Firefox and Safari. It also works with HTML nodes in IE6. However, it appears not to work with XML...
19
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has...
0
by: aredo3604gif | last post by:
I have coded a serie of singly linked lists in ANSI C which I have to use. The lists are then stored in a serie of buckets with chained hash table technique. In the various lists there are nodes...
1
by: sho_nuff | last post by:
Hello, It appears that i may need to create a custom treeview. I have a set of nodes - sometimes, if a user selects an option , i may want to only display a subset of those nodes... and i...
2
by: Marc Jennings | last post by:
Hi there, I have been given a rather poor schema for an XML file in the following format : ><item> > <key>ProductCode</key> > <value>1234-5678</value> > <key>Description</key> >...
1
by: Rory | last post by:
Hi - I've seen quite a few posts that almost match this but haven't found a solution that works. I have an explorer-like application with a treeview in the lefthand pane. When I right-click on a...
2
by: Lee | last post by:
Hello, I am having some problem iterating over nodes. I keep getting the same value using SelectSingleNode even though the nodes does not have that value: XML Document: <?xml...
0
LacrosseB0ss
by: LacrosseB0ss | last post by:
Hey all! I have just started using the TreeView object in asp. There are some other applications I have seen use it and I have copied some of the code from them at work. What happens is on a form,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.