summaryrefslogtreecommitdiff
path: root/test/test-to-c.xsl
diff options
context:
space:
mode:
authorJames Shaw <jshaw@netsurf-browser.org>2007-07-11 21:49:40 +0000
committerJames Shaw <jshaw@netsurf-browser.org>2007-07-11 21:49:40 +0000
commit92311b20c73b13766fb93c123c67e5045356ff49 (patch)
treeb7e7b92eaeb9de350917cefc03fa1d9b2f86924a /test/test-to-c.xsl
parent596d78220d0156e5afd18b2a6832f1ec8b83eec1 (diff)
downloadlibdom-92311b20c73b13766fb93c123c67e5045356ff49.tar.gz
libdom-92311b20c73b13766fb93c123c67e5045356ff49.tar.bz2
Import dom1-interfaces -- autogenned by the w3c DOM test suite.
Partially implemented attribute accessors. svn path=/trunk/dom/; revision=3402
Diffstat (limited to 'test/test-to-c.xsl')
-rw-r--r--test/test-to-c.xsl111
1 files changed, 108 insertions, 3 deletions
diff --git a/test/test-to-c.xsl b/test/test-to-c.xsl
index fe58d99..5502d60 100644
--- a/test/test-to-c.xsl
+++ b/test/test-to-c.xsl
@@ -8,7 +8,7 @@ test representation.
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"><!-- TODO: exslt not currently used -->
<!-- relative to transform -->
- <xsl:param name="interfaces-docname">../build/dom1-interfaces.xml</xsl:param>
+ <xsl:param name="interfaces-docname">dom1-interfaces.xml</xsl:param>
<xsl:param name="target-uri-base">http://www.w3.org/2001/DOM-Test-Suite/tests/Level-1/</xsl:param>
<xsl:output method="text" encoding="UTF-8"/>
<xsl:variable name="domspec" select="document($interfaces-docname)"/>
@@ -16,6 +16,54 @@ test representation.
<!-- swallow any text which we don't understand -->
<xsl:template match="text()"/>
+<!--
+for anything that doesn't match another template,
+we expect this the element to be found in the library located
+at $interfaces-docname.
+
+This should either be a <method> or <attribute>. If it is neither,
+we generate an <xsl:message> reporting that the element is not known.
+-->
+<xsl:template match="*">
+ <!-- the element name matches by this template -->
+ <xsl:variable name="feature" select="local-name(.)"/>
+ <xsl:variable name="interface" select="@interface"/>
+
+ <!--
+ Try to find a method having the @name of $feature.
+ If $interface is defined, make sure search for
+ a match on that interface in the $domspec document.
+ -->
+ <xsl:variable name="method" select="$domspec/library/interface[not($interface) or @name = $interface]/method[@name = $feature]"/>
+ <xsl:choose>
+ <xsl:when test="$method">
+ <xsl:call-template name="produce-method">
+ <xsl:with-param name="method" select="$method"/>
+ <!-- TODO: vardefs not yet done <xsl:with-param name="vardefs" select="$vardefs"/>-->
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <!--
+ Try to find an attribute having the name of $feature.
+ Again, if $interface is defined, restrict the search to
+ that interface
+ -->
+ <xsl:variable name="attribute" select="$domspec/library/interface[not($interface) or @name = $interface]/attribute[@name = $feature]"/>
+ <xsl:choose>
+ <xsl:when test="$attribute">
+ <xsl:call-template name="produce-attribute">
+ <!-- TODO: vardefs not yet done <xsl:with-param name="vardefs" select="$vardefs"/> -->
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:message>Unrecognized element <xsl:value-of select="local-name(.)"/></xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
@@ -31,6 +79,12 @@ int main(int argc, char **argv) {
</xsl:text>
</xsl:template>
+<!--
+================================
+Language construct templates
+================================
+-->
+
<xsl:template match="*[local-name() = 'var']">
<xsl:text> struct </xsl:text><xsl:call-template name="convert_var_type"> <xsl:with-param name="var_type" select="@type"/>
</xsl:call-template> *<xsl:value-of select="@name"/>;
@@ -54,19 +108,70 @@ int main(int argc, char **argv) {
<!--
================================
+DOM templates
+================================
+-->
+
+<xsl:template name="produce-method">
+<!-- TODO: implement me -->
+</xsl:template>
+
+<xsl:template name="produce-attribute">
+ <!-- <xsl:param name="vardefs"/> -->
+ <xsl:variable name="attribName" select="local-name(.)"/>
+ <xsl:choose>
+ <!-- if interface is specified -->
+ <xsl:when test="@interface">
+ <xsl:variable name="interface" select="@interface"/>
+ <xsl:call-template name="produce-specific-attribute">
+ <xsl:with-param name="attribute" select="$domspec/library/interface[@name = $interface]/attribute[@name = $attribName]"/>
+ <!-- <xsl:with-param name="vardefs" select="$vardefs"/> -->
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="produce-specific-attribute">
+ <xsl:with-param name="attribute" select="$domspec/library/interface/attribute[@name = $attribName]"/>
+ <!-- <xsl:with-param name="vardefs" select="$vardefs"/> -->
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="produce-specific-attribute">
+ <!-- <xsl:param name="vardefs"/> -->
+ <xsl:param name="attribute"/>
+ <xsl:variable name="obj" select="@obj"/>
+ <xsl:variable name="value" select="@value"/>
+ <!-- check if attribute name starts with is -->
+ <xsl:if test="@value">
+ <!-- TODO: set attribute to a value -->
+ </xsl:if>
+ <xsl:if test="@var">
+ <xsl:text>
+ err</xsl:text><xsl:text> = TODO_function_call(</xsl:text><xsl:value-of select="@obj"/><xsl:text>, &amp;</xsl:text><xsl:value-of select="@var"/><xsl:text>);
+ assert(err == DOM_NO_ERR);
+</xsl:text>
+
+ </xsl:if>
+</xsl:template>
+
+<!--
+================================
Assert templates
================================
-->
<xsl:template match="*[local-name() = 'assertNotNull']">
<!-- TODO: what does the @id string do, and do we need it here? -->
- <xsl:text> assert(</xsl:text><xsl:value-of select="@actual"/><xsl:text> != NULL);
+ <xsl:text>
+ assert(</xsl:text><xsl:value-of select="@actual"/><xsl:text> != NULL);
</xsl:text>
</xsl:template>
<xsl:template match="*[local-name() = 'assertNull']">
<!-- TODO: what does the @id string do, and do we need it here? -->
- <xsl:text> assert(</xsl:text><xsl:value-of select="@actual"/><xsl:text> == NULL);
+ <xsl:text>
+ assert(</xsl:text><xsl:value-of select="@actual"/><xsl:text> == NULL);
</xsl:text>
</xsl:template>