reference to external xml from xsd
i want to check if an attribute is exist in another xml from an xsd i made
for another xml.
for an example i have this xsd
<xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="models">
<xs:complexType>
<xs:sequence>
<xs:element name="model" maxOccurs="unbounded" minOccurs="1">
<xs:complexType>
<xs:attribute name="name" type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="uniqueModelName">
<xs:selector xpath="./model"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
and i have another xsd
<xs:element name="language">
<xs:complexType>
<xs:sequence>
<xs:element name="word" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="value" maxOccurs="unbounded"
minOccurs="1">
<xs:complexType>
<xs:attribute name="lange"
type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="key" type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
and i want to insure that the attribute named name of the elements named
model in the first xsd are exist in the attribute named key of the element
value in the second xsd
in other words, if there are attributes value named name in the first xsd
doesn't exist in the second xsd, an error must occur.
xml example:
xml for first xsd:
<model name="A"/>
<model name="B"/>
xml for second xsd:
<word key="A">
<value lange="english">Add</value>
<value lange="frensh">ajouter</value>
</word>
it must tell there is an error because there is no tag word in the second
xml that has an attribute B can this happen in xsd :) ?
while this is a correct one
<word key="A">
<value lange="english">Add</value>
<value lange="frensh">ajouter</value>
</word>
<word key="B">
<value lange="english">Add</value>
<value lange="frensh">ajouter</value>
</word>
No comments:
Post a Comment