posted 15 years ago
hi need to build a unique contraint using a xsd .
capabilities will have may capability , but capability should be unique
<?xml version="1.0" encoding="UTF-8"?>
<!--
Description: xsd file Version: 0.3 Update: 09/09/2008 This program is
the confidential and proprietary product of mFormation Technologies
Inc. Any unauthorized use, reproduction or transfer of this program is
strictly prohibited. Copyright � 1999-2008 mFormation Technologies
Inc. (subject to limited distribution and restricted disclosure only.)
All rights reserved.
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://services.mformation.com/MFServices/" xmlns:tns="http://services.mformation.com/MFServices/"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xsd:simpleType name="Type">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Bag" />
<xsd:enumeration value="Sequence" />
<xsd:enumeration value="Literal" />
<xsd:enumeration value="Boolean" />
<xsd:enumeration value="Number" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="Values">
<xsd:sequence>
<xsd:element type="xsd:string" name="Value" minOccurs="0"
maxOccurs="unbounded" nillable="false" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ValidValues">
<xsd:sequence>
<xsd:element type="xsd:string" name="Value" minOccurs="0"
maxOccurs="unbounded" nillable="false" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Capability">
<xsd:sequence>
<xsd:element type="xsd:string" name="Comment" minOccurs="1"
maxOccurs="1" nillable="false" />
<xsd:element type="xsd:string" name="Name" minOccurs="1"
maxOccurs="1" nillable="false" />
<xsd:element type="tns:Type" name="Type" minOccurs="1"
maxOccurs="1" nillable="false" />
<xsd:element type="tns:Values" name="Values" minOccurs="1"
maxOccurs="1" nillable="false" />
<xsd:element type="tns:ValidValues" name="ValidValues"
minOccurs="1" maxOccurs="1" nillable="false" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Capabilities" nillable="false">
<xsd:complexType>
<xsd:sequence>
<xsd:element type="xsd:string" name="SchemaName"
minOccurs="1" maxOccurs="1" nillable="false" />
<xsd:element type="tns:Capability" name="Capability"
minOccurs="1" maxOccurs="unbounded" nillable="false">
<xsd:unique name="un_name">
<xsd:selector xpath="Capability" />
<xsd:field xpath="Name" />
</xsd:unique>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
xml bean validation does not work
for the follwing case
<?xml version="1.0" encoding="utf-8"?>
<tns:Capabilities xmlns:tns="http://services.mformation.com/MFServices/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://services.mformation.com/MFServices/Device_Capabilities_v0.3.xsd">
<tns:SchemaName>TelstraSchemav1.0</tns:SchemaName>
<tns:Capability>
<tns:Comment>Description: Indicates what carkit the device supports. Examples: "Direct connection", "Inductive coupling", "None"</tns:Comment>
<tns:Name>t.Carkit</tns:Name>
<tns:Type>Literal</tns:Type>
<tns:Values>
<tns:Value>Direct connection</tns:Value>
</tns:Values>
<tns:ValidValues>
<tns:Value>Direct connection</tns:Value>
<tns:Value>Inductive coupling</tns:Value>
<tns:Value>None</tns:Value>
</tns:ValidValues>
</tns:Capability>
<tns:Capability>
<tns:Comment>Description: Indicates what carkit the device supports. Examples: "Direct connection", "Inductive coupling", "None"</tns:Comment>
<tns:Name>t.Carkit</tns:Name>
<tns:Type>Literal</tns:Type>
<tns:Values>
<tns:Value>Direct connection</tns:Value>
</tns:Values>
<tns:ValidValues>
<tns:Value>Direct connection</tns:Value>
<tns:Value>Inductive coupling</tns:Value>
<tns:Value>None</tns:Value>
</tns:ValidValues>
</tns:Capability>
</tns:Capabilities>
xml bean validation
C:\Requirements\phase 2\new xsd>validate Device_Capabilities_v0.3.xsd Device_Capabilities_v0.3-duplicate.xml
Device_Capabilities_v0.3-duplicate.xml valid.
C:\Requirements\phase 2\new xsd>