blob: b3410f648a46e0a92aff637662b9d78d7fcd63a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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>
|