hi all,
I'm new with
XML language and I'm analysing if it worth the work to use or not this file format for specific meta data.
I'm want to use
XML Schemas and instance (.
xml) to represent metadada information upon a given system... since my analysis and specification is quite complex I'm posting a little example of my problem (which is very lower than the original

)
I allready anderstand a little bit of
xml format and
xml schemas but not
xml schematron
my problem here (so far...) is to validate not a
xml instance but make a validation upon a
xml schema: i must use a
xml schematron right?
the example is quite simple:
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="XPTO">
<xs:annotation>
<xs:documentation>XML Schema example</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Set1">
<xs:complexType>
<xs:sequence>
<xs:element name="Element" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Set2">
<xs:complexType>
<xs:sequence>
<xs:element name="Element" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Set3">
<xs:complexType>
<xs:sequence>
<xs:element name="Element" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
this schema allows 3 mandatory set, each of them can have a list of none or infinite string...
what i want to validate here is that each list must be exclusive: none of the element that appear on one of the set can appear on any other one of the instance!
for example:
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<XPTO xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\André G. Marques\Desktop\myExample\xpto.xsd">
<Set1>
<Element>"aaa"</Element>
<Element>"bbb"</Element>
<Element>"ccc"</Element>
<Element>"ddd"</Element>
</Set1>
<Set2>
<Element>"aaa"</Element>
<Element>"bbb1"</Element>
</Set2>
<Set3>
<Element>"aaa"</Element>
<Element>"ddd2"</Element>
</Set3>
</XPTO>
is not valid since it got the string element "aaa" repeated at least in 2 list...
The logic is quite simple...
all i have to do is validate/check the elements of the first with the element of the others, doing this recursively, it is not necesary to perform the last valoidation i.e. the last set will never validate with the others since it have been allready checked
but i really don't know how it can be done....
is it possible to validate? must i use schematron??
best regards,
aGM