diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2016-10-19 18:28:08 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2016-10-19 18:28:08 (GMT) |
commit | 7f402e480a04b974617c04142993d3919457d342 (patch) | |
tree | a39cf901d49b9767df3fe076ebf8a06c92277995 /libxml2/xstc/xstc-to-python.xsl | |
parent | 818fd731f62993dc8aa5d07b82e1d1b2c04aae7d (diff) | |
parent | 6c75f0dc676d73c4cbcdca5a9cf05c6797a2ac0b (diff) | |
download | blt-7f402e480a04b974617c04142993d3919457d342.zip blt-7f402e480a04b974617c04142993d3919457d342.tar.gz blt-7f402e480a04b974617c04142993d3919457d342.tar.bz2 |
Merge commit '6c75f0dc676d73c4cbcdca5a9cf05c6797a2ac0b' as 'libxml2'
Diffstat (limited to 'libxml2/xstc/xstc-to-python.xsl')
-rwxr-xr-x | libxml2/xstc/xstc-to-python.xsl | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/libxml2/xstc/xstc-to-python.xsl b/libxml2/xstc/xstc-to-python.xsl new file mode 100755 index 0000000..78d55cd --- /dev/null +++ b/libxml2/xstc/xstc-to-python.xsl @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:ts="TestSuite" version="1.0"
+ xmlns:xl="http://www.w3.org/1999/xlink">
+ <xsl:param name="vendor" select="'NIST'"/>
+ <xsl:output method="text"/>
+
+ <xsl:template match="/">
+ <xsl:text>#!/usr/bin/python -u
+# -*- coding: UTF-8 -*-
+#
+# This file is generated from the W3C test suite description file.
+#
+
+import xstc
+from xstc import XSTCTestRunner, XSTCTestGroup, XSTCSchemaTest, XSTCInstanceTest
+
+xstc.vendor = "</xsl:text><xsl:value-of select="$vendor"/><xsl:text>"
+
+r = XSTCTestRunner()
+
+# Group definitions.
+
+</xsl:text>
+
+ <xsl:apply-templates select="ts:testSet/ts:testGroup" mode="group-def"/>
+<xsl:text>
+
+# Test definitions.
+
+</xsl:text>
+ <xsl:apply-templates select="ts:testSet/ts:testGroup" mode="test-def"/>
+ <xsl:text>
+
+r.run()
+
+</xsl:text>
+
+ </xsl:template>
+
+ <!-- groupName, descr -->
+ <xsl:template match="ts:testGroup" mode="group-def">
+ <xsl:text>r.addGroup(XSTCTestGroup("</xsl:text>
+ <!-- group -->
+ <xsl:value-of select="@name"/><xsl:text>", "</xsl:text>
+ <!-- main schema -->
+ <xsl:value-of select="ts:schemaTest[1]/ts:schemaDocument/@xl:href"/><xsl:text>", """</xsl:text>
+ <!-- group-description -->
+ <xsl:call-template name="str">
+ <xsl:with-param name="str" select="ts:annotation/ts:documentation/text()"/>
+ </xsl:call-template>
+ <xsl:text>"""))
+</xsl:text>
+ </xsl:template>
+
+ <xsl:template name="str">
+ <xsl:param name="str"/>
+ <xsl:choose>
+ <xsl:when test="contains($str, '"')">
+ <xsl:call-template name="str">
+ <xsl:with-param name="str" select="substring-before($str, '"')"/>
+ </xsl:call-template>
+ <xsl:text>'</xsl:text>
+ <xsl:call-template name="str">
+ <xsl:with-param name="str" select="substring-after($str, '"')"/>
+ </xsl:call-template>
+
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$str"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="ts:testGroup" mode="test-def">
+ <xsl:param name="group" select="@name"/>
+ <xsl:for-each select="ts:schemaTest">
+ <!-- groupName, isSchema, Name, Accepted, File, Val, Descr -->
+ <xsl:text>r.addTest(XSTCSchemaTest("</xsl:text>
+ <!-- group -->
+ <xsl:value-of select="$group"/><xsl:text>", "</xsl:text>
+ <!-- test-name -->
+ <xsl:value-of select="@name"/><xsl:text>", </xsl:text>
+ <!-- accepted -->
+ <xsl:value-of select="number(ts:current/@status = 'accepted')"/><xsl:text>, "</xsl:text>
+ <!-- filename -->
+ <xsl:value-of select="ts:schemaDocument/@xl:href"/><xsl:text>", </xsl:text>
+ <!-- validity -->
+ <xsl:value-of select="number(ts:expected/@validity = 'valid')"/><xsl:text>, "</xsl:text>
+ <!-- test-description -->
+ <xsl:value-of select="ts:annotation/ts:documentation/text()"/><xsl:text>"))
+</xsl:text>
+ </xsl:for-each>
+ <xsl:for-each select="ts:instanceTest">
+ <!-- groupName, isSchema, Name, Accepted, File, Val, Descr -->
+ <xsl:text>r.addTest(XSTCInstanceTest("</xsl:text>
+ <!-- group -->
+ <xsl:value-of select="$group"/><xsl:text>", "</xsl:text>
+ <!-- test-name -->
+ <xsl:value-of select="@name"/><xsl:text>", </xsl:text>
+ <!-- accepted -->
+ <xsl:value-of select="number(ts:current/@status = 'accepted')"/><xsl:text>, "</xsl:text>
+ <!-- filename -->
+ <xsl:value-of select="ts:instanceDocument/@xl:href"/><xsl:text>", </xsl:text>
+ <!-- validity -->
+ <xsl:value-of select="number(ts:expected/@validity = 'valid')"/><xsl:text>, "</xsl:text>
+ <!-- test-description -->
+ <xsl:value-of select="ts:annotation/ts:documentation/text()"/><xsl:text>"))
+</xsl:text>
+ </xsl:for-each>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file |