Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  Viewpoint XML Schema    Element and Attribute validation

Moderators: e_phoenix13
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Junior Member
Posted
Hi,
I need to validate both xml element and attribute in schema.

<shipto>
<name Rno="1231" version="1">Ola Nordmann</name>
<shipto>

In the above xml, i need to validate that attribute Rno should be of 4 character in length,version should be of single digit and the element value should be of characters.
Please sugguest possible solution.
Many thanks
 
Posts: 1 | Registered: July 30, 2008Reply With QuoteEdit or Delete MessageReport This Post
Junior Member
Posted Hide Post
Use a schema something like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="shipto">
<xs:sequence>
<xs:element name="name" type="nameType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="nameType">
<xs:simpleContent>
<xs:restriction base="xs:string">
<xs:attributeGroup ref="nameAttributes"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
<xs:attributeGroup name="nameAttributes">
<xs:attribute name="Rno" type="RnoAttribute" use="required"/>
<xs:attribute name="version" type="versionAttribute" use="required"/>
</xs:attributeGroup>
<xs:simpleType name="RnoAttribute">
<xs:restriction base="xs:string">
<xs:length value="4"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="versionAttribute">
<xs:restriction base="xs:integer">
<xs:length value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
 
Posts: 3 | Registered: June 08, 2009Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

Viewpoint Developer Central    Viewpoint Forums    Viewpoint Forums  Hop To Forum Categories  Viewpoint XML Schema    Element and Attribute validation