Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > problem Validating sequnece of Tag values using schema

Thread Tools

problem Validating sequnece of Tag values using schema

Posts: n/a
In the following XML, I need to validate the values provided in Order
tag using schema.

<?xml version="1.0" encoding="UTF-8"?>
<Control xmlnssi="">
<DisplayName>Sequence #</DisplayName> <!-- Column Name to be
<Display>Y</Display> <!-- N -> Hide and Y -> Show -->
<DisplayName>Doc. Type</DisplayName>
<DisplayName>Distr. #</DisplayName>

Following are the cases to be validated:

Order: 1,2,3 - Valid
Order: 2,1,3 - Valid
Order: 3,2,1 -Valid
Order: 1,1,1 - Invalid
Order: 1,3,4 - Invalid
Order: 4,5,6 - Invalid

Thanks in advance,
Reply With Quote
Posts: n/a
Here is the solution---


<?xml version="1.0" encoding="UTF-8"?>



<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlnss=""
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Transaction">
<!-- Permit between 1 and 3 -->
<xs:choice minOccurs="0">
<xs:element ref="WidgetItem" minOccurs="0" maxOccurs="3" />
<!-- Enforce that if any widgets are present then they are uniquely
numbered -->
<xs:key name="WidgetKey">
<xs:selector xpath="WidgetItem" />
<xs:field xpath="Order" />

<!-- A type representing a single widget -->
<xs:complexType name="Widget">
<xs:element name="Order">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="3"/>
<!-- The main elements for a Transaction-->
<xs:element name="WidgetItem" type="Widget" />

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
How to programatically assign a validating schema using Xerces? Duncan Smith XML 1 12-15-2003 04:05 PM
Validating xml with xsd schema using xerces Yona XML 0 10-29-2003 01:04 PM
Validating with in-memory Xml Schema using Xerces Jasmin Wason XML 0 08-01-2003 03:15 PM