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

detect duplicate element in SAX

The client will pass a xsd file to me through my API and it will be
parsed using SAX in JAVA. The XSD format is like following:
<xs:complexType name="Item">
<xs:all>
<xs:element name="item-id" type="xs:string" />
<xs:element name="item-name" type="xs:string" />
</xs:all>
</xs:complexType>

So there will be quite a few Items in the xsd. I want to make sure the
value of <item-idis unique... So is there any algorithm that I can
use to detect that?

Sep 24 '06 #1
2 1281
us***@yahoo.com wrote:
So there will be quite a few Items in the xsd. I want to make sure the
value of <item-idis unique... So is there any algorithm that I can
use to detect that?
If the name attribute isn't being validated against a schema or DTD
which says its value must be unique, you'll have to implement that in
your application code. Since you said you're working in Java, the
simplest approach would be to have your SAX handler maintain a Set
(hashset, treeset, or whatever version suits your data), checking for
whether a prior instance of that value has appeared; if not add it to
the set, but if so announce an error.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 24 '06 #2
Sorry; I misread that the first time around. (Didn't quite wake up today.)

To use schema to declare that the value of an Element must be unique, see

http://www.w3.org/TR/2004/REC-xmlsch...nt_Definitions
and the xs:unique directive.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 25 '06 #3

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

Similar topics

9
by: NiQ | last post by:
Hello every one, this is about an array of string and may be have done several time before but i need it and wasnt able to find it so here is the problem i have an array of strings with contains...
0
by: cr | last post by:
Could somebody tell me whether the use of duplicate element definition or reference are permitted in XML schemas? For example: <complexType name="PurchaseOrderType"> <sequence> <element...
13
by: vega | last post by:
How do I detect empty tags if I have the DOM document? For example: <br /> and <br></br> I tried org.w3c.dom.Node.getFirstChild(), it returns null for both <br /> and <br></br> I also tried...
157
by: Dennis | last post by:
Is there some way --using, say, DOM or javascript-- to detect the current pixel width and/or height of a relatively sized table or of one of its columns or rows. I'm going to be writing javascript...
9
by: vbportal | last post by:
Hi, I would like to add BitArrays to an ArrayList and then remove any duplicates - can someone please help me forward. I seem to have (at leaset ;-) )2 problems/lack of understanding (see test...
4
by: Dmitry Kulinich | last post by:
Guys! Is there are any possibility to create nodes with duplicate names and different types in XSD? I've read the whole specification and tried in a many different ways, but not successfull. ...
1
by: nanie | last post by:
i am new in vb. i would like to know the vb script for detect duplicate data entry. this is the system for booking bus.the bus have unique number.nobody can book the same bus.the system will give the...
9
by: DotNetNewbie | last post by:
Hello, I need a simple hash algorithm that will detect duplicate content in my application. I want to hash not just the content, but a few other parameters also like EmployeeID and...
1
by: ranjitha55 | last post by:
but it is displaying al values der in xml file.it should avoid reading duplicate values ,pls help me.. my code is, public class nm { public static void main(String argv) { try { File...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.