Test case 008

Example 7 (date split as a list of nodes)

Back to the test suite

Schema (correct)

c.rng

<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:if="http://namespaces.xmlschemata.org/xvif/iframe" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
 <start>
  <if:pipe>
   <if:transform type="http://simonstl.com/ns/fragments/">
    <if:apply>
     <fragmentRules xmlns="http://simonstl.com/ns/fragments/">
      <fragmentRule pattern="^[ \t\n]*([0-9]{4})-([0-9]{2})-([0-9]{2})[ \t\n]*$">
       <applyTo>
        <element localName="date"/>
       </applyTo>
       <produce>
        <element localName="year"/>
        <element localName="month"/>
        <element localName="day"/>
       </produce>
      </fragmentRule>
     </fragmentRules>
    </if:apply>
   </if:transform> 
   <if:validate type="http://relaxng.org/ns/structure/1.0">
    <if:apply>
     <element name="date">
      <element name="year">
       <data type="unsignedInt">    
        <param name="minInclusive">2000</param>
       </data>
      </element>
      <element name="month">
       <data type="unsignedByte">   
        <param name="maxInclusive">12</param>
       </data>
      </element>
      <element name="day">
       <data type="unsignedByte">   
        <param name="maxInclusive">31</param>
       </data>
      </element>
     </element>
    </if:apply>
   </if:validate>
  </if:pipe>
 </start>
</grammar>

Instance document (invalid)

1.i.xml: [download] [try it]

<date>x y</date>

Instance document (invalid)

2.i.xml: [download] [try it]

<date>1999-09-18</date>

Instance document (valid)

3.v.xml: [download] [try it]

<date>2002-09-18</date>

Instance document (valid)

4.v.xml: [download] [try it]

<date> 2002-09-18 </date>

Instance document (invalid)

5.i.xml: [download] [try it]

<date>2002-09--18</date>

Instance document (invalid)

6.i.xml: [download] [try it]

<date>2002-09-18-</date>

Instance document (invalid)

7.i.xml: [download] [try it]

<date>2002-09-18-a</date>

Instance document (invalid)

8.i.xml: [download] [try it]

<date>2001-13-18</date>

Instance document (invalid)

9.i.xml: [download] [try it]

<date>2001-14.5-18</date>

Instance document (invalid)

10.i.xml: [download] [try it]

<date>2001-09.-18</date>

Instance document (invalid)

11.i.xml: [download] [try it]

<date>2001-09-32</date>

Instance document (invalid)

12.i.xml: [download] [try it]

<date>-2001-09-18</date>

Instance document (valid)

13.v.xml: [download] [try it]

<date>2001-12-31</date>

Instance document (invalid)

14.i.xml: [download] [try it]

<date>0000002001-012-031</date>

Instance document (invalid)

15.i.xml: [download] [try it]

<date>
 2001
 -
 12
 -
 31
</date>

Instance document (valid)

16.v.xml: [download] [try it]

<date>2001-11-31</date>