VirtualBox

source: vbox/trunk/src/libs/libxml2-2.6.30/xstc/xstc-to-python.xsl@ 11632

Last change on this file since 11632 was 6076, checked in by vboxsync, 17 years ago

Merged dmik/s2 branch (r25959:26751) to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 3.7 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2<xsl:stylesheet
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:ts="TestSuite" version="1.0"
5 xmlns:xl="http://www.w3.org/1999/xlink">
6 <xsl:param name="vendor" select="'NIST'"/>
7 <xsl:output method="text"/>
8
9 <xsl:template match="/">
10 <xsl:text>#!/usr/bin/python -u
11# -*- coding: UTF-8 -*-
12#
13# This file is generated from the W3C test suite description file.
14#
15
16import xstc
17from xstc import XSTCTestRunner, XSTCTestGroup, XSTCSchemaTest, XSTCInstanceTest
18
19xstc.vendor = "</xsl:text><xsl:value-of select="$vendor"/><xsl:text>"
20
21r = XSTCTestRunner()
22
23# Group definitions.
24
25</xsl:text>
26
27 <xsl:apply-templates select="ts:testSet/ts:testGroup" mode="group-def"/>
28<xsl:text>
29
30# Test definitions.
31
32</xsl:text>
33 <xsl:apply-templates select="ts:testSet/ts:testGroup" mode="test-def"/>
34 <xsl:text>
35
36r.run()
37
38</xsl:text>
39
40 </xsl:template>
41
42 <!-- groupName, descr -->
43 <xsl:template match="ts:testGroup" mode="group-def">
44 <xsl:text>r.addGroup(XSTCTestGroup("</xsl:text>
45 <!-- group -->
46 <xsl:value-of select="@name"/><xsl:text>", "</xsl:text>
47 <!-- main schema -->
48 <xsl:value-of select="ts:schemaTest[1]/ts:schemaDocument/@xl:href"/><xsl:text>", """</xsl:text>
49 <!-- group-description -->
50 <xsl:call-template name="str">
51 <xsl:with-param name="str" select="ts:annotation/ts:documentation/text()"/>
52 </xsl:call-template>
53 <xsl:text>"""))
54</xsl:text>
55 </xsl:template>
56
57 <xsl:template name="str">
58 <xsl:param name="str"/>
59 <xsl:choose>
60 <xsl:when test="contains($str, '&quot;')">
61 <xsl:call-template name="str">
62 <xsl:with-param name="str" select="substring-before($str, '&quot;')"/>
63 </xsl:call-template>
64 <xsl:text>'</xsl:text>
65 <xsl:call-template name="str">
66 <xsl:with-param name="str" select="substring-after($str, '&quot;')"/>
67 </xsl:call-template>
68
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:value-of select="$str"/>
72 </xsl:otherwise>
73 </xsl:choose>
74 </xsl:template>
75
76 <xsl:template match="ts:testGroup" mode="test-def">
77 <xsl:param name="group" select="@name"/>
78 <xsl:for-each select="ts:schemaTest">
79 <!-- groupName, isSchema, Name, Accepted, File, Val, Descr -->
80 <xsl:text>r.addTest(XSTCSchemaTest("</xsl:text>
81 <!-- group -->
82 <xsl:value-of select="$group"/><xsl:text>", "</xsl:text>
83 <!-- test-name -->
84 <xsl:value-of select="@name"/><xsl:text>", </xsl:text>
85 <!-- accepted -->
86 <xsl:value-of select="number(ts:current/@status = 'accepted')"/><xsl:text>, "</xsl:text>
87 <!-- filename -->
88 <xsl:value-of select="ts:schemaDocument/@xl:href"/><xsl:text>", </xsl:text>
89 <!-- validity -->
90 <xsl:value-of select="number(ts:expected/@validity = 'valid')"/><xsl:text>, "</xsl:text>
91 <!-- test-description -->
92 <xsl:value-of select="ts:annotation/ts:documentation/text()"/><xsl:text>"))
93</xsl:text>
94 </xsl:for-each>
95 <xsl:for-each select="ts:instanceTest">
96 <!-- groupName, isSchema, Name, Accepted, File, Val, Descr -->
97 <xsl:text>r.addTest(XSTCInstanceTest("</xsl:text>
98 <!-- group -->
99 <xsl:value-of select="$group"/><xsl:text>", "</xsl:text>
100 <!-- test-name -->
101 <xsl:value-of select="@name"/><xsl:text>", </xsl:text>
102 <!-- accepted -->
103 <xsl:value-of select="number(ts:current/@status = 'accepted')"/><xsl:text>, "</xsl:text>
104 <!-- filename -->
105 <xsl:value-of select="ts:instanceDocument/@xl:href"/><xsl:text>", </xsl:text>
106 <!-- validity -->
107 <xsl:value-of select="number(ts:expected/@validity = 'valid')"/><xsl:text>, "</xsl:text>
108 <!-- test-description -->
109 <xsl:value-of select="ts:annotation/ts:documentation/text()"/><xsl:text>"))
110</xsl:text>
111 </xsl:for-each>
112 </xsl:template>
113
114</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette