473,466 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

unique integer id as attribute

Hi,

I want to use a unique ID attribute, which should be an integer value.
I tried the solution below with xpath, but the xml seems to be valid,
even if there are two equal ids. Any idea why?
My XSD
---------------------------------------------------------------------
<xs:element name="sample">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="one" maxOccurs="10">
<xs:complexType>
<xs:attribute name="anothertxt" type="xs:string"/>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="two" maxOccurs="10">
<xs:complexType>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="three" maxOccurs="10">
<xs:complexType>
<xs:attribute name="sequenceid" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="seqid">
<xs:selector xpath=".//sample"/>
<xs:field xpath="@sequenceid"/>
</xs:key>
</xs:element>
---------------------------------------------------------------------

My XML
---------------------------------------------------------------------
<sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sample.xsd">
<one sequenceid="1"/>
<one sequenceid="2"/>
<two sequenceid="3"/>
<two sequenceid="3"/>
</sample>
---------------------------------------------------------------------
Jul 20 '05 #1
4 1706


Mario wrote:

I want to use a unique ID attribute, which should be an integer value.
I tried the solution below with xpath, but the xml seems to be valid,
even if there are two equal ids. Any idea why?
My XSD
---------------------------------------------------------------------
<xs:element name="sample"> <xs:key name="seqid">
<xs:selector xpath=".//sample"/>
Why the path to sample if the sequenceid attribute is on the other
elements, e.g. one or two?
<xs:field xpath="@sequenceid"/> My XML
---------------------------------------------------------------------
<sample xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sample.xsd">
<one sequenceid="1"/>
<one sequenceid="2"/>
<two sequenceid="3"/>
<two sequenceid="3"/>
</sample>


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
I thought this might be the only possibility to get the sequence ID
unique for all element-attributes below <sample>... is this wrong?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3


Mario wrote:
I thought this might be the only possibility to get the sequence ID
unique for all element-attributes below <sample>... is this wrong?


You should be able to use
<xs:selector xpath=".//*">
to match any descendant element, at least that is my current reading of
the XML schema specification. Try that.
It should also be possible to list alternatives e.g.
<xs:selector xpath="one | two | three">
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4
Hey cool, that way it rocks. Thx a lot!!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5

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

Similar topics

1
by: Ulf Heyder | last post by:
Hello everyone, I want to add a unique constraint to a XSD I created. After I modified validation (XMLSpy, Castor-0.9.5 marshaller) of my example (see below) against the XSD (also see below)...
0
by: magister | last post by:
Hello, I want to have a unique Quesiton Id key for each question under section. Not for every question in the Typed DataSet. Is there anyway I can do this...? Thanks, here is my typed...
2
by: sachinik19 | last post by:
Hi, xml file : ------------- <?xml version='1.0'?> <query xmlns='jabber:iq:privacy' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="jabber:iq:privacy privacy.xsd">...
2
by: smachin1000 | last post by:
Hi All, In the sample schema & document below, I'd like the attribute "name" to be unique for all function elements under function_list. The tools I'm using (XML Spy and xmllint) all validate...
2
by: Miguel Isidoro | last post by:
Hi all, I am trying to include a xsd:unique element in my schema to make an attribute of an element unique at the whole document level. Consider the following xml fragment: <Form>...
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...
2
by: pstachy | last post by:
Hi again! I have another issue. I would like the attribute of the tag <invoice> to be unique. Made the following schema but unfortunately it doesn't validate. Could someone please indicate what is...
1
by: Asko Telinen | last post by:
Hi all. I´m a bit newbie writing xml schemas. Is it possible to define xml element that must have unique attribute values in same level. For example if i have a xml - document: <list>...
0
by: pr | last post by:
I have the following sample XML File: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <parent> <child ref="1"><grandchild>tom</grandchild></child> <child...
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
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,...
1
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.