Jump to content

Validating "Linked" values in multiple nodes


Guest wsucougar86

Recommended Posts

Guest wsucougar86
<Element ID="01" Item="Element01">	 <ElementID>01</ElementID>	 ...</Element>

For the XML sample above, is there anyway to ensure that the value of all three values (two attributes of "Element" and innertext value of "ElementID") all contain the same numeric value? I know I can use <xs:pattern> to require that ID be two numeric digits, etc. But if the "ID" attribute is 02 then ElementID needs to be 02 and the Item attribute must be "Element02" -- is it possible to link values like that in an XML schema??Hopefully that makes sense, but let me know if it doesn't. I appreciate the help!

Link to comment
Share on other sites

You can specify one of theese attributes as being of type xs:ID (or an extension/restriction of it), and the other one of xs:IDREF.Note that xs:IDREF items can't be xs:IDs at the same time. In other words, their xs:ID counterpart must be present in the document.Also, xs:IDs can't be the same between each other (I think). That is, you can't have for example "ID" and "Item" declared as xs:ID, and use "01" as a value for both.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...