+Tue Nov 12 18:17:24 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+ * libexslt/functions.c: applied patch for param visibility from
+ Shaun McCance. Changed variable scoping in accordance with
+ Shaun's suggestions. This fixed problem reported on the list
+ by Bernd Lang
+ * tests/exslt/functions/function.8.[xml,xsl,out], Makefile.am:
+ regression test for above
+
Sat Nov 8 13:27:12 CET 2003 Daniel Veillard <daniel@veillard.com>
* libexslt/libexslt.3: applied improvement patch from Jonathan Wakely
xmlXPathObjectPtr obj, oldResult, ret;
exsltFuncData *data;
exsltFuncFunctionData *func;
- xmlNodePtr paramNode, oldInsert, fake;
+ xmlNodePtr paramNode, oldInsert, fake, content = NULL;
+ int oldBase;
xsltStackElemPtr params = NULL, param;
xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt);
int i;
ctxt->error = XPATH_INVALID_ARITY;
return;
}
- if (func->content != NULL)
+ if (func->content != NULL) {
paramNode = func->content->prev;
+ content = func->content;
+ }
else
paramNode = NULL;
if ((paramNode == NULL) && (func->nargs != 0)) {
"param == NULL\n");
return;
}
- /* defaulted params */
+
+ /* set params */
for (i = func->nargs; (i > nargs) && (paramNode != NULL); i--) {
- param = xsltParseStylesheetCallerParam (tctxt, paramNode);
- param->next = params;
- params = param;
paramNode = paramNode->prev;
+ if (content != NULL)
+ content = content->prev;
}
- /* set params */
while ((i-- > 0) && (paramNode != NULL)) {
obj = valuePop(ctxt);
/* FIXME: this is a bit hackish */
(const xmlChar *)"fake", NULL);
oldInsert = tctxt->insert;
tctxt->insert = fake;
+ /*
+ * In order to give the function variables a new 'scope' we
+ * change varsBase in the context.
+ */
+ oldBase = tctxt->varsBase;
+ tctxt->varsBase = tctxt->varsNr;
xsltApplyOneTemplate (tctxt, xmlXPathGetContextNode(ctxt),
- func->content, NULL, params);
+ content, NULL, params);
tctxt->insert = oldInsert;
+ tctxt->varsBase = oldBase; /* restore original scope */
if (params != NULL)
xsltFreeStackElemList(params);
function.3.out function.3.xml function.3.xsl \
function.4.out function.4.xml function.4.xsl \
function.5.out function.5.xml function.5.xsl \
- function.6.out function.6.xml function.6.xsl
+ function.6.out function.6.xml function.6.xsl \
+ function.7.out function.7.xml function.7.xsl \
+ function.8.out function.8.xml function.8.xsl
all:
--- /dev/null
+typedef struct Pcmdb_TestHeadDatabase Pcmdb_TestHeadDatabase;
+
--- /dev/null
+<?xml version="1.0"?>
+<!--
+<!DOCTYPE adt SYSTEM "adt.dtd">
+-->
+
+<adt>
+
+ <prosa-name>Test Head Database</prosa-name>
+ <prefix>pcmdb</prefix>
+
+ <author>Max Mueller</author>
+ <date>August 16, 2002</date>
+
+ <brief>This adt holds relevant information regarding the test head
+ of the tester.</brief>
+ <detailed>
+ There is only one instance of the adt in the system, and you can
+ query the adt regarding parameters of the current installed test
+ head.
+ </detailed>
+
+</adt>
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:func="http://exslt.org/functions"
+ extension-element-prefixes="func"
+>
+<xsl:output method="text" encoding="ISO-8859-1" omit-xml-declaration="yes" />
+
+<xsl:variable name="prefix" select="/adt/prefix" />
+<xsl:variable name="prosaName" select="/adt/prosa-name" />
+
+<xsl:variable name="suffix" select="'.h'" />
+
+<!-- makes all letters upper case -->
+<func:function name="func:upper">
+ <xsl:param name="in" />
+ <func:result select="translate($in,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
+</func:function>
+
+<!-- makes all letters lower case -->
+<func:function name="func:lower">
+ <xsl:param name="in" />
+ <func:result select="translate($in,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')" />
+</func:function>
+
+<!-- makes first letter (of every word) upper case -->
+<!-- converts first x to X and every _x to _X -->
+<!-- and every ' x' to 'X' (note the space) -->
+<func:function name="func:firstUpper">
+ <xsl:param name="in" />
+ <xsl:variable name="tmp" select="$in"/>
+ <xsl:choose>
+ <!-- Call first upper for each word -->
+ <xsl:when test="contains(substring($tmp,2),' ')">
+ <func:result select="concat(
+ func:firstUpper(substring-before($tmp,' ')),
+ func:firstUpper(substring-after(substring($tmp,2),' ')))" />
+ </xsl:when>
+ <!-- read over '_' -->
+ <xsl:when test="contains(substring($tmp,1,1),'_')">
+ <func:result select="concat('_',
+ func:firstUpper(substring($tmp,2)))" />
+ </xsl:when>
+ <!-- Make first character upper case and continue -->
+ <xsl:otherwise>
+ <func:result select="concat(func:upper(substring($tmp,1,1)),
+ substring($tmp,2))" />
+ </xsl:otherwise>
+ </xsl:choose>
+</func:function>
+
+<xsl:template match="adt">
+
+ <xsl:variable name="prosaNameLower" select="func:lower($prosaName)" />
+
+ <xsl:value-of select="concat( 'typedef struct ',
+ func:firstUpper($prefix), '_', func:firstUpper($prosaNameLower), ' ',
+ func:firstUpper($prefix), '_', func:firstUpper($prosaNameLower),
+ '; ' )" />
+
+</xsl:template>
+
+<!-- finished -->
+</xsl:stylesheet>