Using keyref in xml schema for attribute with list of values

I am trying to develop a scheme for checking the XML format that is already used in the application (there is not much space for redesigning xml).

I am trying to use the key and keyref elements of an XML schema dictionary to verify identity restrictions.

One of the special problems is how xml models relationships from one to several.

<spaceships> <spaceship guns="gun1 gun2 gun3"/> </spaceships> <guns> <gun id="gun1"/> <gun id="gun2"/> <gun id="gun3"/> </guns> 

I came up with this key pair / keyref in my circuit

 <xs:key name="gunKey"> <xs:selector xpath="guns/gun" /> <xs:field xpath="@id" /> </xs:key> <xs:keyref name="gunRef" refer="gunKey"> <xs:selector xpath="spaceships/spaceship" /> <xs:field xpath="@guns" /> </xs:keyref> 

This is not supported by protests against herces:

The key "gunRef" with the value "gun1 gun2 gun3" was not found to limit the identity of the element.

Is there any sense in expressing in the schema that the value of the list is a list of links, separated by commas, to another object and still get the advantage of checking for identity restrictions?

+7
source share
1 answer

I'm afraid that you cannot create a link for such an attribute as guns="gun1 gun2 gun3" , because gun1 gun2 gun3 is a simple string that is not automatically divided into 3 separate parts.

UPDATE 1: If you want to map such attributes, look at this QA: XML Schema; multiple of the list of valid attribute values

+1
source

All Articles