Home | History | Annotate | Download | only in xsdtest
      1 <?xml version="1.0"?>
      2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      3 
      4 <xsl:strip-space elements="xsdtest datatype equiv class"/>
      5 
      6 <xsl:output indent="yes" encoding="utf-8"/>
      7 
      8 <xsl:template match="xsdtest">
      9   <testSuite>
     10     <xsl:apply-templates/>
     11   </testSuite>
     12 </xsl:template>
     13 
     14 <xsl:template match="datatype">
     15 <testSuite>
     16 <documentation>Datatype <xsl:value-of select="@name"/></documentation>
     17 <testCase>
     18 <requires datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
     19 <correct>
     20 <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
     21          datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
     22   <data type="{@name}">
     23     <xsl:for-each select="param">
     24       <param name="{@name}"><xsl:value-of select="."/></param>
     25     </xsl:for-each>
     26   </data>
     27 </element>
     28 </correct>
     29 <xsl:apply-templates select="valid|invalid"/>
     30 </testCase>
     31 <xsl:apply-templates select="equiv/class|length|lessThan|incomparable"/>
     32 </testSuite>
     33 </xsl:template>
     34 
     35 <xsl:template match="valid">
     36  <xsl:call-template name="valid"/>
     37 </xsl:template>
     38 
     39 <xsl:template match="invalid">
     40  <xsl:call-template name="invalid"/>
     41 </xsl:template>
     42 
     43 <xsl:template name="valid">
     44   <valid>
     45     <xsl:apply-templates select="@internalSubset"/>
     46     <doc>
     47       <xsl:copy-of select="namespace::*"/>
     48       <xsl:value-of select="."/>
     49     </doc>
     50   </valid>
     51 </xsl:template>
     52 
     53 <xsl:template name="invalid">
     54   <invalid>
     55     <xsl:apply-templates select="@internalSubset"/>
     56     <doc>
     57       <xsl:copy-of select="namespace::*"/>
     58       <xsl:value-of select="."/>
     59     </doc>
     60   </invalid>
     61 </xsl:template>
     62 
     63 <xsl:template match="@internalSubset">
     64   <xsl:param name="doc" select="'doc'"/>
     65   <xsl:attribute name="dtd">
     66     <xsl:text>
     67 &lt;!DOCTYPE </xsl:text>
     68     <xsl:value-of select="$doc"/>
     69     <xsl:text> [
     70 </xsl:text>
     71     <xsl:value-of select="."/>
     72     <xsl:text>
     73 ]></xsl:text>
     74   </xsl:attribute>
     75 </xsl:template>
     76 
     77 <xsl:template match="class">
     78 <testCase>
     79 <correct>
     80   <xsl:for-each select="value[1]">
     81     <xsl:apply-templates select="@internalSubset">
     82       <xsl:with-param name="doc">element</xsl:with-param>
     83     </xsl:apply-templates>
     84     <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
     85          datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
     86       <value>
     87         <xsl:copy-of select="namespace::*"/>
     88         <xsl:attribute name="type"><xsl:value-of select="../../../@name"/></xsl:attribute>
     89         <xsl:value-of select="."/>
     90       </value>
     91     </element>
     92   </xsl:for-each>
     93 </correct>
     94 <xsl:for-each select="value[position() != 1]">
     95   <xsl:call-template name="valid"/>
     96 </xsl:for-each>
     97 <xsl:for-each select="preceding-sibling::class/value|following-sibling::class/value">
     98   <xsl:call-template name="invalid"/>
     99 </xsl:for-each>
    100 </testCase>
    101 </xsl:template>
    102 
    103 <xsl:template match="length">
    104 <testCase>
    105 <correct>
    106 <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
    107          datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    108   <data type="{../@name}">
    109     <param name="length"><xsl:value-of select="@value"/></param>
    110   </data>
    111 </element>
    112 </correct>
    113 <xsl:call-template name="valid"/>
    114 </testCase>
    115 
    116 <testCase>
    117 <correct>
    118 <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
    119          datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    120   <data type="{../@name}">
    121     <param name="length"><xsl:value-of select="@value + 1"/></param>
    122   </data>
    123 </element>
    124 </correct>
    125 <xsl:call-template name="invalid"/>
    126 </testCase>
    127 
    128 <xsl:if test="@value != 0">
    129   <testCase>
    130   <correct>
    131   <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
    132 	   datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    133     <data type="{../@name}">
    134       <param name="length"><xsl:value-of select="@value - 1"/></param>
    135     </data>
    136   </element>
    137   </correct>
    138   <xsl:call-template name="invalid"/>
    139   </testCase>
    140 </xsl:if>
    141 
    142 </xsl:template>
    143 
    144 <xsl:template match="lessThan">
    145 <testCase>
    146 <correct>
    147   <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
    148 	   datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    149     <data type="{../@name}">
    150       <param name="minExclusive">
    151         <xsl:value-of select="value[1]"/>
    152       </param>
    153     </data>
    154    </element>
    155 </correct>
    156 <valid>
    157 <doc>
    158 <xsl:value-of select="value[2]"/>
    159 </doc>
    160 </valid>
    161 <invalid>
    162 <doc>
    163 <xsl:value-of select="value[1]"/>
    164 </doc>
    165 </invalid>
    166 </testCase>
    167 <testCase>
    168 <correct>
    169   <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
    170 	   datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    171     <data type="{../@name}">
    172       <param name="minExclusive">
    173         <xsl:value-of select="value[2]"/>
    174       </param>
    175     </data>
    176    </element>
    177 </correct>
    178 <invalid>
    179 <doc>
    180 <xsl:value-of select="value[1]"/>
    181 </doc>
    182 </invalid>
    183 <invalid>
    184 <doc>
    185 <xsl:value-of select="value[2]"/>
    186 </doc>
    187 </invalid>
    188 </testCase>
    189 </xsl:template>
    190 
    191 <xsl:template match="incomparable">
    192 <testCase>
    193 <correct>
    194   <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
    195 	   datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    196     <data type="{../@name}">
    197       <param name="minExclusive">
    198         <xsl:value-of select="value[1]"/>
    199       </param>
    200     </data>
    201    </element>
    202 </correct>
    203 <invalid>
    204 <doc>
    205 <xsl:value-of select="value[2]"/>
    206 </doc>
    207 </invalid>
    208 <invalid>
    209 <doc>
    210 <xsl:value-of select="value[1]"/>
    211 </doc>
    212 </invalid>
    213 </testCase>
    214 <testCase>
    215 <correct>
    216   <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
    217 	   datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    218     <data type="{../@name}">
    219       <param name="minExclusive">
    220         <xsl:value-of select="value[2]"/>
    221       </param>
    222     </data>
    223    </element>
    224 </correct>
    225 <invalid>
    226 <doc>
    227 <xsl:value-of select="value[1]"/>
    228 </doc>
    229 </invalid>
    230 <invalid>
    231 <doc>
    232 <xsl:value-of select="value[2]"/>
    233 </doc>
    234 </invalid>
    235 </testCase>
    236 </xsl:template>
    237 
    238 </xsl:stylesheet>
    239