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

Wrapping multiple identically named elements into a new element using XSLT
Xml schema uniqueness in entire subtree
dynamic xml nodes using xslt
xpst0003 xquery syntax error
Xsl anchor attribute
How to get start and end of a week of a specific date using xslt?
how to select elements when the root element has a lot of attributes
xsd select multiple values from enumeration or equivalent type
Issue with XSL loops and linefeeds
what is the xpath of this element
Openerp module output not generated properly
trasfer one excel sheet into multiple xml content in mule
R : Get attribute value from an XML
How to use the ref attribute without allowing multiple roots
XSLT - Multiple parent groups of same name
multiple attributes in different combinations

Categories

HOME
scikit-learn
adal
spark-streaming
wakanda
github-for-windows
depth
jelastic
sublimetext
xbee
carousel
cq5
regular-language
crystal-reports-2013
title
lanczos
dkim
vimdiff
plist
startup
xcodebuild
radgridview
docx
html5-appcache
jersey-1.0
asciidoctor-pdf
interpreter
ckfinder
beautifier
nstimer
paperjs
errbot
tizen-tv
realm-mobile-platform
finagle
boost-asio
python-2.6
mustache
turfjs
jbutton
spring-security4
hreflang
browser-extension
fiware-cygnus
docfx
google-knowledge-graph
loading
diacritics
p4merge
comparison-operators
trigonometry
watchface
plr
monkey-testing
httr
servermanager
jboss-4.2.x
context-switch
cmp
universal-analytics
gameplay-kit
vibrate
filenet
docpad
stax
omxplayer
installshield-2010
delta
firebase-security
mediametadataretriever
qbxml
user-management
character-replacement
decimalformat
dynatree
oracle-spatial
toolkit
apache-commons-daemon
cross-join
punycode
create.js
wxformbuilder
spring-remoting
android-framework
synapse
koala
git-repo
gwt-openlayers
spring-3
visual-studio-express
http-patch
away3d
inappsettingskit
asdf
twisted.web
pyunit
adobe-media-server
boost-signals
appjs
tournament
pylucene
uipagecontrol
instantiationexception
maven-1
request-headers
filesystemobject
sun
windows-identity
sifr3
xpsdocument
wysiwym
change-management
great-circle

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