XML Schema to validate each value in an NMTOKENS attribute list

Given this XML file:

<users blessed="phrogz alians">
  <user name="phrogz"  id="42" />
  <user name="lachtok" id="3"  />
  <user name="vielee"  id="5"  />
  <user name="alians"  id="17" />
</users>

...is it possible to create an XSD key/keyref style validation that ensures that each value in the the blessed list matches against an existing user/@name?

If this is not possible with XSD, is it possible with RelaxNG?

Answers


No, it's not possible with XSD 1.0. It's straightforward in XSD 1.1, of course, using assertions:

Uniqueness (if defined at the level of the users element):

<xsl:assert test="count(@blessed) = count(distinct-values(@blessed))"/>

Referential integrity (if defined at the level of the users element):

<xsl:assert test="every $t in data(@blessed) satisfies $t = user/@name"/>

Need Your Help

PHP error fetching json file

php json web

Can someone help why my JSON file can't show? I beginner for JSON. This is my code, its only show blank document. I am learning this tutorial from this website

Javascript jQuery Map reloadable

javascript jquery map draggable reload

Similar questions have been asked before, but there is something I need all the others map di not require: