diff options
author | William M. Brack <wbrack@src.gnome.org> | 2004-01-14 08:55:52 +0000 |
---|---|---|
committer | William M. Brack <wbrack@src.gnome.org> | 2004-01-14 08:55:52 +0000 |
commit | fbb1eec975d3d9830b14d164c0eeed5e1b98fca0 (patch) | |
tree | 30584b73a589c310140657aec481a993388df30b /tests | |
parent | 62742bd4fea91e9b6b6feeef3e53bb9811807903 (diff) | |
download | libxslt-fbb1eec975d3d9830b14d164c0eeed5e1b98fca0.tar.gz libxslt-fbb1eec975d3d9830b14d164c0eeed5e1b98fca0.tar.bz2 libxslt-fbb1eec975d3d9830b14d164c0eeed5e1b98fca0.zip |
added test case for math functions on nodesets generated by exslt:node-set
* tests/exslt/math/max.3.xsl, tests/exslt/math/max.3.xml,
tests/exslt/math/max.3.out, tests/exslt/math/Makefile.am:
added test case for math functions on nodesets generated by
exslt:node-set
Diffstat (limited to 'tests')
-rw-r--r-- | tests/exslt/math/max.3.out | 4 | ||||
-rw-r--r-- | tests/exslt/math/max.3.xml | 9 | ||||
-rw-r--r-- | tests/exslt/math/max.3.xsl | 80 |
3 files changed, 93 insertions, 0 deletions
diff --git a/tests/exslt/math/max.3.out b/tests/exslt/math/max.3.out new file mode 100644 index 00000000..d23881c5 --- /dev/null +++ b/tests/exslt/math/max.3.out @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?> +Largest number value: 500 +Largest number value (computed by function foo:getMaxVal): 500 +Largest number value (computed by function foo:getMaxVal2): 500 diff --git a/tests/exslt/math/max.3.xml b/tests/exslt/math/max.3.xml new file mode 100644 index 00000000..79a00e10 --- /dev/null +++ b/tests/exslt/math/max.3.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> +<rootelement> + <childelement val="100"/> + <childelement val="200"/> + <childelement val="500"/> + <childelement val="300"/> + <childelement val="nothing"/> +</rootelement> + diff --git a/tests/exslt/math/max.3.xsl b/tests/exslt/math/max.3.xsl new file mode 100644 index 00000000..b3410f64 --- /dev/null +++ b/tests/exslt/math/max.3.xsl @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="iso-8859-1" standalone="no"?> + +<!DOCTYPE xsl:stylesheet [ + +<!-- namespace for SVG --> +<!ENTITY svgns "http://www.w3.org/2000/svg"> +<!-- namespace for XSLT --> +<!ENTITY xsltns "http://www.w3.org/1999/XSL/Transform"> + +<!-- namespaces for several EXSLT extension modules (see + http://www.exslt.org for description) --> +<!ENTITY cns "http://exslt.org/common"> <!-- EXSLT-Common --> +<!ENTITY fns "http://exslt.org/functions"> <!-- EXSLT-Functions --> +<!ENTITY mns "http://exslt.org/math"> <!-- EXSLT-Math --> + +<!ENTITY foons "http://www.foo.org/bar"> + +]> + +<xsl:stylesheet version="1.0" + xmlns="&svgns;" + xmlns:xsl="&xsltns;" + xmlns:exsl="&cns;" + xmlns:func="&fns;" + xmlns:math="&mns;" + xmlns:foo="&foons;" + extension-element-prefixes="exsl func math foo" + exclude-result-prefixes="xsl exsl func math"> + +<xsl:output method="xml" indent="yes" encoding="iso-8859-1" standalone="yes"/> + +<xsl:template match="/"> + + <xsl:text>Largest number value: </xsl:text> + <xsl:value-of + select="math:max(rootelement/childelement/@val[string(number(.)) != 'NaN'])"/> + <xsl:text> +Largest number value (computed by function foo:getMaxVal): </xsl:text> + <xsl:value-of select="foo:getMaxVal(rootelement/childelement)"/> + <xsl:text> +Largest number value (computed by function foo:getMaxVal2): </xsl:text> + <xsl:value-of select="foo:getMaxVal2(rootelement/childelement)"/> +</xsl:template> + +<func:function name="foo:getMaxVal"> + <xsl:param name="nodes"/> + + <xsl:variable name="resNodes"> + <xsl:for-each select="$nodes"> + <xsl:if test="@val and string(number(@val)) != 'NaN'"> + <dummynode> + <xsl:value-of select="@val"/> + </dummynode> + </xsl:if> + </xsl:for-each> + </xsl:variable> + + <xsl:variable name="resNodeSet" select="exsl:node-set($resNodes)"/> + + <func:result select="math:max($resNodeSet/*)"/> +</func:function> + +<func:function name="foo:getMaxVal2"> + <xsl:param name="nodes"/> + + <xsl:variable name="resNodes"> + <xsl:for-each select="$nodes"> + <xsl:if test="@val and string(number(@val)) != 'NaN'"> + <dummynode> + <xsl:value-of select="@val"/> + </dummynode> + </xsl:if> + </xsl:for-each> + </xsl:variable> + + <func:result select="math:max(exsl:node-set($resNodes)/*)"/> +</func:function> + +</xsl:stylesheet> + |