1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Rep Power

    How to validate this xml input?

    I'm new to XML and I need help. I have thos XML code on which I have to make a scheme validator:

    <?xml version="1.0" encoding="UTF-8"?>
        <family pol="m">Peter</family>
        <family pol="w">Penz</family>
        <family pol="w">Penzov</family>

    The xml scheme must follow these rules:

    family, age and email must be strictly in order

    family - must be repeated once and maximum 20 symbols

    age - must be repeated once, number between 1 and 100

    email - must be repeated once, 0 or 1, String between 5 and 10 symbols

    Would you help me please to create a very basic example?

    So far I have done this:

    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    <xs:element name="user">
          <xs:element name="family" type="xs:string">
         <xs:restriction base="xs:string">
                <xs<img src="http://images.devshed.com/fds/smilies/tongue.gif" border="0" alt="" title="Stick Out Tongue" class="inlineimg" />attern value="[a-zA-Z][a-zA-Z][a-zA-Z]"/>
            <xs:enumeration value="family" maxOccurs="1"/>
                <xs:length value="20"/>
          </xs:element name="family" type="xs:string">
          <xs:element name="age" type="xs:intreger">
        <xs:restriction base="xs:integer">
                <xs:minInclusive value="1"/>
                <xs:maxInclusive value="100"/>
            <xs:enumeration value="age" maxOccurs="1"/>
          </xs:element name="age" type="xs:intreger">
          <xs:element name="email" type="xs:string">
         <xs:restriction base="xs:string">
                 <xs:minLength value="5"/>
                 <xs:maxLength value="10"/>
             <xs:enumeration value="email" maxOccurs="1"/>
          </xs:element name="email" type="xs:string">
    Last edited by rcbandit; June 22nd, 2013 at 02:12 AM.

IMN logo majestic logo threadwatch logo seochat tools logo