Multiple XML Validation Scenario
Posted: Thu Sep 26, 2013 9:47 am
Hi,
I have one XSD specifying valid DataTypes, each Datatype has a Key "ID". Another XSD is meant to uses these DataType-IDs in a KeyRef. So that the DataType-KeyRef can only contain values, that exist in a specific XML-file in the environment. How do I create a validation scenario like this? I managed to set the DataType-Key unique in the DataType-XSD. Once I create XML from the second XSD that uses the KeyRef, all fields are marked as "unique or out of scope". I assume this is because the XML defining the valid DataTypes is not taken into account. I tried the Oxygen tutorial on creating validation scenarios, but including the relevant XML file does not work. Is such validation scenario possible at all? How do I "tell" Oxygen in which XML to look for the valid values?
DataTypes.xsd
The second XSD uses the KeyRef:
...
Many thanks in advance!
AS
I have one XSD specifying valid DataTypes, each Datatype has a Key "ID". Another XSD is meant to uses these DataType-IDs in a KeyRef. So that the DataType-KeyRef can only contain values, that exist in a specific XML-file in the environment. How do I create a validation scenario like this? I managed to set the DataType-Key unique in the DataType-XSD. Once I create XML from the second XSD that uses the KeyRef, all fields are marked as "unique or out of scope". I assume this is because the XML defining the valid DataTypes is not taken into account. I tried the Oxygen tutorial on creating validation scenarios, but including the relevant XML file does not work. Is such validation scenario possible at all? How do I "tell" Oxygen in which XML to look for the valid values?
DataTypes.xsd
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sdt="DataTypes.xsd"
xmlns="DataTypes.xsd" elementFormDefault="qualified" targetNamespace="DataTypes.xsd"
attributeFormDefault="unqualified">
<xs:element name="DataTypes">
<xs:complexType>
<xs:sequence>
<xs:element name="DataType" type="sdt:DataTypeDef" maxOccurs="unbounded"
minOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:unique name="UniqueDataTypes">
<xs:selector xpath="sdt:DataType"/>
<xs:field xpath="sdt:ID"/>
</xs:unique>
</xs:element>
<xs:complexType name="DataTypeDef">
<xs:sequence>
<xs:element maxOccurs="1" minOccurs="1" name="ID" type="xs:string">
<xs:key name="DataTypeKey">
<xs:selector xpath="sdt:DataType"/>
<xs:field xpath="sdt:ID"/>
</xs:key>
</xs:element>
<xs:element maxOccurs="1" minOccurs="1" name="ImplementationClass" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Code: Select all
<?xml version="1.1" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sdt="DataTypes.xsd"
xmlns="ClientProfile.xsd" targetNamespace="ClientProfile.xsd" xmlns:cp="ClientProfile.xsd"
elementFormDefault="qualified">
<xs:import namespace="DataTypes.xsd" schemaLocation="DataTypes.xsd"/>
Code: Select all
<xs:complexType name="StyrisDataTypeReference">
<xs:sequence>
<xs:element name="DataType" type="xs:string">
<xs:keyref name="DataProfileStyrisDataTypeKeyRef" refer="sdt:StyrisDataTypeKey">
<xs:selector xpath="sdt:StyrisDataType"/>
<xs:field xpath="sdt:ID"/>
</xs:keyref>
</xs:element>
</xs:sequence>
</xs:complexType>
AS