473,408 Members | 2,839 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,408 software developers and data experts.

strategies for making elements unique

I have to work with an existing xml where there is a root element and all
other elements are children of the root (in other words there is no nesting
or hierarchy), e.g.
<myroot>
<A>adata</A>
<B>bdata</B>
<C>cdata</C>
<A>otheradata</A>
</myroot>

Unfortunately there are a lot of rules for the elements, such as choices
(e.g. A or B), groups which are mandatory or optional or repetitive, etc. and
the elements can be used in various different groups. It is possible to write
a schema which validates this accurately, so creating such xml and validating
it is fine.
However, when receiving such data from somebody else, I would greatly
appreciate if the parser could actually let me know that it has e.g. found
<A> in the first (maybe optional) group. I have looked at various strategies:
1. use a default attribute which gives extra information. doesn't work,
because when compiling the schema, elements of same hierarchy level and same
name may not have different default attributes.
2. use an id. Seems to be the same problem: id is an attribute. also I
haven't really found out how to work with ids.
3. use unhandledattributes. this would be a great method, if I could get the
unhandledattributes from the element definition while reading the elements
with validatingreader. However, there is no such method. The only info which
I can glean during reading is SchemaType, which returns the definition of the
simple or complex type (including any unhadledattributes on the type
definition). however, the type for <A> is the same wherever it is used, so
that is of no help either.
4. I suppose I could read the SOM in parallel with the xml, but that really
amounts to replicating the work which the parser does!

Does anybody out there have a suggestion?
Thanks in advance.
Lisa
Nov 12 '05 #1
2 1175
If you use .net framework 2.0 beta2, there is a new validating reader
available in System.Xml which can be created using the static
XmlReader.Create methods. That reader provides a SchemaInfo Property which
contains, among other properties, a SchemaElement property which points to
the SOM element declaration, from where you can fetch the unhandled
attributes or any other data that you might need.
"Lisa" <Li**@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.com...
I have to work with an existing xml where there is a root element and all
other elements are children of the root (in other words there is no nesting or hierarchy), e.g.
<myroot>
<A>adata</A>
<B>bdata</B>
<C>cdata</C>
<A>otheradata</A>
</myroot>

Unfortunately there are a lot of rules for the elements, such as choices
(e.g. A or B), groups which are mandatory or optional or repetitive, etc. and the elements can be used in various different groups. It is possible to write a schema which validates this accurately, so creating such xml and validating it is fine.
However, when receiving such data from somebody else, I would greatly
appreciate if the parser could actually let me know that it has e.g. found
<A> in the first (maybe optional) group. I have looked at various strategies: 1. use a default attribute which gives extra information. doesn't work,
because when compiling the schema, elements of same hierarchy level and same name may not have different default attributes.
2. use an id. Seems to be the same problem: id is an attribute. also I
haven't really found out how to work with ids.
3. use unhandledattributes. this would be a great method, if I could get the unhandledattributes from the element definition while reading the elements
with validatingreader. However, there is no such method. The only info which I can glean during reading is SchemaType, which returns the definition of the simple or complex type (including any unhadledattributes on the type
definition). however, the type for <A> is the same wherever it is used, so
that is of no help either.
4. I suppose I could read the SOM in parallel with the xml, but that really amounts to replicating the work which the parser does!

Does anybody out there have a suggestion?
Thanks in advance.
Lisa

Nov 12 '05 #2
Dear Zafar,
thanks for the info - that is great news!
Regards,
Lisa

"Zafar Abbas" wrote:
If you use .net framework 2.0 beta2, there is a new validating reader
available in System.Xml which can be created using the static
XmlReader.Create methods. That reader provides a SchemaInfo Property which
contains, among other properties, a SchemaElement property which points to
the SOM element declaration, from where you can fetch the unhandled
attributes or any other data that you might need.
"Lisa" <Li**@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.com...
I have to work with an existing xml where there is a root element and all
other elements are children of the root (in other words there is no

nesting
or hierarchy), e.g.
<myroot>
<A>adata</A>
<B>bdata</B>
<C>cdata</C>
<A>otheradata</A>
</myroot>

Unfortunately there are a lot of rules for the elements, such as choices
(e.g. A or B), groups which are mandatory or optional or repetitive, etc.

and
the elements can be used in various different groups. It is possible to

write
a schema which validates this accurately, so creating such xml and

validating
it is fine.
However, when receiving such data from somebody else, I would greatly
appreciate if the parser could actually let me know that it has e.g. found
<A> in the first (maybe optional) group. I have looked at various

strategies:
1. use a default attribute which gives extra information. doesn't work,
because when compiling the schema, elements of same hierarchy level and

same
name may not have different default attributes.
2. use an id. Seems to be the same problem: id is an attribute. also I
haven't really found out how to work with ids.
3. use unhandledattributes. this would be a great method, if I could get

the
unhandledattributes from the element definition while reading the elements
with validatingreader. However, there is no such method. The only info

which
I can glean during reading is SchemaType, which returns the definition of

the
simple or complex type (including any unhadledattributes on the type
definition). however, the type for <A> is the same wherever it is used, so
that is of no help either.
4. I suppose I could read the SOM in parallel with the xml, but that

really
amounts to replicating the work which the parser does!

Does anybody out there have a suggestion?
Thanks in advance.
Lisa


Nov 12 '05 #3

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

Similar topics

7
by: lawrence | last post by:
2 Questions: 1.) Can anyone think of a way to speed up this function? It is terribly slow. I plan to reduce the number of directories to 3, which I guess will speed it up in the end. 2.) This...
2
by: M. Katz | last post by:
I'm trying to create a heirarchical linked list of sorts, and I'm looking for advice as to how best to set up the arrays. In other languages, I might use a pointer array to other pointer arrays,...
0
by: |-|erc | last post by:
Hi! Small challenge for you. The index.php uses this file and calls layout(). Take a look at www.chatty.net this file draws the chat login box on the right. I traced the CHAT button it submits...
24
by: superprad | last post by:
Is there an easy way to grab the Unique elements from a list? For Example: data = what I am looking for is the unique elements 0.4 and 0.9 with their index from the list. Probably something...
6
by: bosgoverde | last post by:
I've tried several ways to achieve a xsd schema for the following xml example, but failed to do so. Valid: <Person> <Interest>Movies</Interest> <Interest>Computers</Interest> </Person>...
2
by: libsfan01 | last post by:
hi! i have written a function to make visible elements with a certain id. however i intended it to be used to make visible multiple elements but it only appears to switch on the first element it...
1
by: daldridge | last post by:
I have a unique-elements/sorting question (who doesn't?), but haven't yet been able to get appropriate template/select/for-each processing working. I don't fully grok the Muenchian technique yet...
15
by: Prisoner at War | last post by:
Okay, I think I'll soon be getting all the JavaScript/CSS/DHTML- related "site mechanics" wrapped up...at least until I decide on real Ajax-style interactivity next year! But until then, I'd be...
0
by: origami.takarana | last post by:
Intrusion Detection Strategies ----------------------------------- Until now, we’ve primarily discussed monitoring in how it relates to intrusion detection, but there’s more to an overall...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.