XML Schema validation with schematron
Posted: Thu Apr 27, 2006 4:06 pm
hi all,
I'm new with XML language and I'm analysing if it woth the work to use or not this file format.
I'm want to use XML Schemas and instance (.xml) to represent metadada information upon system... since my analysis and specification is quite complex I'm posting a little example of my problem (which very lower than the original )
I allready anderstand xml format and xml schemas but i'm totally awhere of 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:
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:
is not valid since it got the string element "aaa" repeated at least in 2 list...
is it possible to validate? must i use schematron??
best regards,
aGM.
I'm new with XML language and I'm analysing if it woth the work to use or not this file format.
I'm want to use XML Schemas and instance (.xml) to represent metadada information upon system... since my analysis and specification is quite complex I'm posting a little example of my problem (which very lower than the original )
I allready anderstand xml format and xml schemas but i'm totally awhere of 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>
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 it possible to validate? must i use schematron??
best regards,
aGM.