123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <?xml version="1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:strip-space elements="xsdtest datatype equiv class"/>
- <xsl:output indent="yes" encoding="utf-8"/>
- <xsl:template match="xsdtest">
- <testSuite>
- <xsl:apply-templates/>
- </testSuite>
- </xsl:template>
- <xsl:template match="datatype">
- <testSuite>
- <documentation>Datatype <xsl:value-of select="@name"/></documentation>
- <testCase>
- <requires datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"/>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{@name}">
- <xsl:for-each select="param">
- <param name="{@name}"><xsl:value-of select="."/></param>
- </xsl:for-each>
- </data>
- </element>
- </correct>
- <xsl:apply-templates select="valid|invalid"/>
- </testCase>
- <xsl:apply-templates select="equiv/class|length|lessThan|incomparable"/>
- </testSuite>
- </xsl:template>
- <xsl:template match="valid">
- <xsl:call-template name="valid"/>
- </xsl:template>
- <xsl:template match="invalid">
- <xsl:call-template name="invalid"/>
- </xsl:template>
- <xsl:template name="valid">
- <valid>
- <xsl:apply-templates select="@internalSubset"/>
- <doc>
- <xsl:copy-of select="namespace::*"/>
- <xsl:value-of select="."/>
- </doc>
- </valid>
- </xsl:template>
- <xsl:template name="invalid">
- <invalid>
- <xsl:apply-templates select="@internalSubset"/>
- <doc>
- <xsl:copy-of select="namespace::*"/>
- <xsl:value-of select="."/>
- </doc>
- </invalid>
- </xsl:template>
- <xsl:template match="@internalSubset">
- <xsl:param name="doc" select="'doc'"/>
- <xsl:attribute name="dtd">
- <xsl:text>
- <!DOCTYPE </xsl:text>
- <xsl:value-of select="$doc"/>
- <xsl:text> [
- </xsl:text>
- <xsl:value-of select="."/>
- <xsl:text>
- ]></xsl:text>
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="class">
- <testCase>
- <correct>
- <xsl:for-each select="value[1]">
- <xsl:apply-templates select="@internalSubset">
- <xsl:with-param name="doc">element</xsl:with-param>
- </xsl:apply-templates>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <value>
- <xsl:copy-of select="namespace::*"/>
- <xsl:attribute name="type"><xsl:value-of select="../../../@name"/></xsl:attribute>
- <xsl:value-of select="."/>
- </value>
- </element>
- </xsl:for-each>
- </correct>
- <xsl:for-each select="value[position() != 1]">
- <xsl:call-template name="valid"/>
- </xsl:for-each>
- <xsl:for-each select="preceding-sibling::class/value|following-sibling::class/value">
- <xsl:call-template name="invalid"/>
- </xsl:for-each>
- </testCase>
- </xsl:template>
- <xsl:template match="length">
- <testCase>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{../@name}">
- <param name="length"><xsl:value-of select="@value"/></param>
- </data>
- </element>
- </correct>
- <xsl:call-template name="valid"/>
- </testCase>
- <testCase>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{../@name}">
- <param name="length"><xsl:value-of select="@value + 1"/></param>
- </data>
- </element>
- </correct>
- <xsl:call-template name="invalid"/>
- </testCase>
- <xsl:if test="@value != 0">
- <testCase>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{../@name}">
- <param name="length"><xsl:value-of select="@value - 1"/></param>
- </data>
- </element>
- </correct>
- <xsl:call-template name="invalid"/>
- </testCase>
- </xsl:if>
- </xsl:template>
- <xsl:template match="lessThan">
- <testCase>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{../@name}">
- <param name="minExclusive">
- <xsl:value-of select="value[1]"/>
- </param>
- </data>
- </element>
- </correct>
- <valid>
- <doc>
- <xsl:value-of select="value[2]"/>
- </doc>
- </valid>
- <invalid>
- <doc>
- <xsl:value-of select="value[1]"/>
- </doc>
- </invalid>
- </testCase>
- <testCase>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{../@name}">
- <param name="minExclusive">
- <xsl:value-of select="value[2]"/>
- </param>
- </data>
- </element>
- </correct>
- <invalid>
- <doc>
- <xsl:value-of select="value[1]"/>
- </doc>
- </invalid>
- <invalid>
- <doc>
- <xsl:value-of select="value[2]"/>
- </doc>
- </invalid>
- </testCase>
- </xsl:template>
- <xsl:template match="incomparable">
- <testCase>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{../@name}">
- <param name="minExclusive">
- <xsl:value-of select="value[1]"/>
- </param>
- </data>
- </element>
- </correct>
- <invalid>
- <doc>
- <xsl:value-of select="value[2]"/>
- </doc>
- </invalid>
- <invalid>
- <doc>
- <xsl:value-of select="value[1]"/>
- </doc>
- </invalid>
- </testCase>
- <testCase>
- <correct>
- <element xmlns="http://relaxng.org/ns/structure/1.0" name="doc"
- datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <data type="{../@name}">
- <param name="minExclusive">
- <xsl:value-of select="value[2]"/>
- </param>
- </data>
- </element>
- </correct>
- <invalid>
- <doc>
- <xsl:value-of select="value[1]"/>
- </doc>
- </invalid>
- <invalid>
- <doc>
- <xsl:value-of select="value[2]"/>
- </doc>
- </invalid>
- </testCase>
- </xsl:template>
- </xsl:stylesheet>
|