xml


How to force unique fields in XML


Say I've developed the following complexType:
<xs:complexType name="item">
<xs:attribute name="first" type="xs:nonNegativeInteger" use="required"/>
<xs:attribute name="second" type="xs:nonNegativeInteger" use="required"/>
</xs:complexType>
and then I create a sequence of those items:
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="item" type="item" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Within the sequence, I want to ensure that all of the items' values for first & second are unique across the sequence. So this sequence would be legal
<items>
<item first="0" second="1"/>
<item first="2" second="3"/>
</items>
But these sequences need to be illegal:
<items>
<item first="0" second="0"/> <- illegal because the 0 is used twice within this item
<item first="2" second="3"/>
</items>
<items>
<item first="0" second="1"/>
<item first="0" second="3"/> <- illegal because the 0 is used twice across two items in the same sequence
</items>
<items>
<item first="0" second="1"/>
<item first="2" second="0"/> <- also illegal because the 0 is used twice across two items in the same sequence
</items>
So basically once an integer is used, it can never be used again within the sequence, regardless of whether it was originally used for the first or second value. Is there a way to do this with the unique tag?
I've been able to come up with ones like
<xs:unique name="uniqueFirst">
<xs:selector xpath="item"/>
<xs:field xpath="#first"/>
</xs:unique>
<xs:unique name="uniqueSecond">
<xs:selector xpath="item"/>
<xs:field xpath="#second"/>
</xs:unique>
these ensure that a value used for an item's first value can't get used for another item's first, and a second can't get used for another second, but it doesn't catch the crossover conditions where a value used as one item's first is then re-used as another item's second

Related Links

Write a tr069 emulate client with perl?
R programming XML: accessing duplicate node
Cannot find the declaration of element 'xs:schema'
Webservice schema validation not working
How to define XSD element to have multiple children, all of which are simple and only have attributes?
App Engine - Java Cache Control wont work
XML list types required for WCF
What is the meaning of xs:mixed without elements?
Copy xml element with whole tree
how to get unique record count for each location_Name by Record_No when RECORD_TYPE='ERROR' with XSLT
XML and accented charachters
XSLT grouping based on XML element values
REST and links: middle ground?
What's Haskell's attitude towards Unicode in XML?
Specific How-To Minimally Style XML with XSLT after adding over-arching categories
Why is my XSLT style sheet not pulling values from my XML file for a table?

Categories

HOME
microsoftgraph
oracle12c
wakanda
apache-jena
ns-3
error-handling
database-normalization
xbee
google-apps
permissions
gluon-mobile
extjs4.2
pattern-matching
32bit-64bit
minecraft-forge
endeca
windows-ce
project-intu
line
supervisor
selenium-ide
libusb
coin3d
keytool
video-editing
google-picker
jmp
sigma.js
nodemcu
direct3d11
motion-detection
nstimer
fractions
comparable
calculation
code-snippets
raft
xdocreport
z-notation
linq-to-objects
resolution
avcapturedevice
openal
gitlist
dtsearch
configurationmanager
rserve
mongotemplate
arq
dt
type-theory
offline.js
vibrate
swingworker
structuremap4
filenet
gets
pacemaker
dotnetnuke-7
jquery-jscrollpane
simevents
embedding
freepbx
hadoop-partitioning
mobiledoc-kit
jaunt-api
character-replacement
file-move
text-search
typemock
google-refine
document-repository
psr-4
raygun
xml-namespaces
create.js
named-parameters
matrix-inverse
functional-java
memset
buffering
android-usb
modular
nevron
joomla3.1
adobe-media-server
entity-attribute-value
landscape-portrait
umra
presentation-layer
ruby-1.8
metaweblog
aspmenu
burndowncharts
complex-event-processing
fail-fast-fail-early
online-storage
idatareader

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App