You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2001/09/06 22:08:09 UTC
cvs commit: xml-xalan/test/tests/extensions/library libraryDifference01.xml libraryDifference01.xsl libraryDistinct01.xml libraryDistinct01.xsl libraryEvaluate01.xml libraryEvaluate01.xsl libraryHasSameNodes01.xml libraryHasSameNodes01.xsl libraryIntersection01.xml libraryIntersection01.xsl libraryNodeset01.xml libraryNodeset01.xsl libraryNodeset02.xml libraryTokenize01.xml libraryTokenize01.xsl
curcuru 01/09/06 13:08:09
Added: test/tests/extensions/library libraryDifference01.xml
libraryDifference01.xsl libraryDistinct01.xml
libraryDistinct01.xsl libraryEvaluate01.xml
libraryEvaluate01.xsl libraryHasSameNodes01.xml
libraryHasSameNodes01.xsl libraryIntersection01.xml
libraryIntersection01.xsl libraryNodeset01.xml
libraryNodeset01.xsl libraryNodeset02.xml
libraryTokenize01.xml libraryTokenize01.xsl
Log:
Basic tests of built-in library extensions in Xalan-J 2.x
Revision Changes Path
1.1 xml-xalan/test/tests/extensions/library/libraryDifference01.xml
Index: libraryDifference01.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<list name="abc">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="abc2">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="aaa">
<item>a</item>
<item>a</item>
<item>a</item>
</list>
<list name="xyz">
<item>x</item>
<item>y</item>
<item>z</item>
</list>
<list name="aab">
<item>a</item>
<item>a</item>
<item>b</item>
</list>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryDifference01.xsl
Index: libraryDifference01.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<xsl:output indent="yes"/>
<!-- FileName: libraryDifference01.xsl -->
<!-- Creator: Shane Curcuru -->
<!-- Purpose: Basic test of difference(ns, ns) extension function -->
<xsl:template match="doc">
<out>
<test desc="selects abc (abc, xyz)">
<xsl:copy-of select="xalan:difference(list[@name='abc']/item, list[@name='xyz']/item)"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:difference(list[@name='abc']/item, list[@name='xyz']/item)"/>
</test>
<test desc="selects xyz (xyz, abc)">
<xsl:copy-of select="xalan:difference(list[@name='xyz']/item, list[@name='abc']/item)"/>
</test>
<test desc="selects nothing (abc, abc)">
<xsl:copy-of select="xalan:difference(list[@name='abc']/item, list[@name='abc']/item)"/>
</test>
<test desc="selects nothing (abc, abc and parent)">
<xsl:copy-of select="xalan:difference(list[@name='abc'], list[@name='abc'])"/>
</test>
<test desc="selects bc (abc, abc[1])">
<xsl:copy-of select="xalan:difference(list[@name='abc']/item, list[@name='abc']/item[1])"/>
</test>
<test desc="selects nothing (abc[1], abc)">
<xsl:copy-of select="xalan:difference(list[@name='abc']/item[1], list[@name='abc']/item)"/>
</test>
<test desc="selects a (abc[1], abc[2])">
<xsl:copy-of select="xalan:difference(list[@name='abc']/item[1], list[@name='abc']/item[2])"/>
</test>
</out>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/test/tests/extensions/library/libraryDistinct01.xml
Index: libraryDistinct01.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<list name="abc">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="abc2">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="aaa">
<item>a</item>
<item>a</item>
<item>a</item>
</list>
<list name="xyz">
<item>x</item>
<item>y</item>
<item>z</item>
</list>
<list name="aab">
<item>a</item>
<item>a</item>
<item>b</item>
</list>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryDistinct01.xsl
Index: libraryDistinct01.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<!-- Indent just for readability -->
<xsl:output indent="yes"/>
<!-- FileName: libraryDistinct01.xsl -->
<!-- Creator: Shane Curcuru -->
<!-- Purpose: Basic test of distinct(ns, ns) extension function -->
<xsl:template match="doc">
<out>
<test desc="selects abc">
<xsl:copy-of select="xalan:distinct(list[@name='abc']/item)"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:distinct(list[@name='abc']/item)"/>
</test>
<test desc="selects a from aaa">
<xsl:copy-of select="xalan:distinct(list[@name='aaa']/item)"/>
</test>
<test desc="selects xyz">
<xsl:copy-of select="xalan:distinct(list[@name='xyz']/item)"/>
</test>
<test desc="selects ab from aab">
<xsl:copy-of select="xalan:distinct(list[@name='aab']/item)"/>
</test>
<test desc="selects abc from abc|abc2">
<xsl:copy-of select="xalan:distinct(list[@name='abc']/item | list[@name='abc2']/item)"/>
</test>
<test desc="selects abcxyz from abc|aab|xyz">
<xsl:copy-of select="xalan:distinct(list[@name='abc']/item | list[@name='aab']/item | list[@name='xyz']/item)"/>
</test>
</out>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/test/tests/extensions/library/libraryEvaluate01.xml
Index: libraryEvaluate01.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<list>
<item number="1">1</item>
<item number="2">2</item>
<item number="3">3</item>
<list>
<item number="1">1.1</item>
<item number="2">2.2</item>
<item number="3">3.3</item>
<item number="10">10.01</item>
</list>
<item number="10">10</item>
</list>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryEvaluate01.xsl
Index: libraryEvaluate01.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<!-- FileName: libraryEvaluate01.xsl -->
<!-- Document: http://www.w3.org/TR/xslt -->
<!-- DocVersion: 19991116 -->
<!-- Creator: Shane Curcuru -->
<!-- Purpose: Basic test of evaluate() extension function -->
<xsl:param name="param1">sum(item)</xsl:param>
<xsl:template match="doc">
<out>
<sum-expr>
<xsl:value-of select="$param1"/>
</sum-expr>
<xsl:apply-templates select="list"/>
</out>
</xsl:template>
<xsl:template match="list">
<xsl:element name="listout">
<xsl:attribute name="sum-function">
<xsl:value-of select="sum(item)"/>
</xsl:attribute>
<xsl:attribute name="sum-evaluate">
<!-- Use string() to force the variable to be a string to be evaluated -->
<xsl:value-of select="xalan:evaluate( string($param1) )"/>
</xsl:attribute>
<xsl:apply-templates select="list"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/test/tests/extensions/library/libraryHasSameNodes01.xml
Index: libraryHasSameNodes01.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<list name="abc">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="abc2">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="aaa">
<item>a</item>
<item>a</item>
<item>a</item>
</list>
<list name="xyz">
<item>x</item>
<item>y</item>
<item>z</item>
</list>
<list name="aab">
<item>a</item>
<item>a</item>
<item>b</item>
</list>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryHasSameNodes01.xsl
Index: libraryHasSameNodes01.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<xsl:output indent="yes"/>
<!-- FileName: libraryHasSameNodes01.xsl -->
<!-- Creator: Shane Curcuru -->
<!-- Purpose: Basic test of hasSameNodes(ns, ns) extension function -->
<xsl:template match="doc">
<out>
<test desc="selects true (abc, abc)">
<xsl:copy-of select="xalan:hasSameNodes(list[@name='abc']/item, list[@name='abc']/item)"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:hasSameNodes(list[@name='abc']/item, list[@name='abc']/item)"/>
</test>
<test desc="selects true (abc, abc and parent)">
<xsl:copy-of select="xalan:hasSameNodes(list[@name='abc'], list[@name='abc'])"/>
</test>
<test desc="selects false (abc, xyz)">
<xsl:copy-of select="xalan:hasSameNodes(list[@name='abc']/item, list[@name='xyz']/item)"/>
</test>
<test desc="selects false (abc, abc2)">
<xsl:copy-of select="xalan:hasSameNodes(list[@name='abc']/item, list[@name='abc2']/item)"/>
</test>
<test desc="selects false (abc, abc[1])">
<xsl:copy-of select="xalan:hasSameNodes(list[@name='abc']/item, list[@name='abc']/item[1])"/>
</test>
<test desc="selects false (abc[1], abc)">
<xsl:copy-of select="xalan:hasSameNodes(list[@name='abc']/item[1], list[@name='abc']/item)"/>
</test>
<test desc="selects true (abc[1], abc[1])">
<xsl:copy-of select="xalan:hasSameNodes(list[@name='abc']/item[1], list[@name='abc']/item[1])"/>
</test>
</out>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/test/tests/extensions/library/libraryIntersection01.xml
Index: libraryIntersection01.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<list name="abc">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="abc2">
<item>a</item>
<item>b</item>
<item>c</item>
</list>
<list name="aaa">
<item>a</item>
<item>a</item>
<item>a</item>
</list>
<list name="xyz">
<item>x</item>
<item>y</item>
<item>z</item>
</list>
<list name="aab">
<item>a</item>
<item>a</item>
<item>b</item>
</list>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryIntersection01.xsl
Index: libraryIntersection01.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<xsl:output indent="yes"/>
<!-- FileName: libraryIntersection01.xsl -->
<!-- Creator: Shane Curcuru -->
<!-- Purpose: Basic test of intersection(ns, ns) extension function -->
<xsl:template match="doc">
<out>
<test desc="selects abc (abc, abc)">
<xsl:copy-of select="xalan:intersection(list[@name='abc']/item, list[@name='abc']/item)"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:intersection(list[@name='abc']/item, list[@name='abc']/item)"/>
</test>
<test desc="selects abc (abc, abc and parent)">
<xsl:copy-of select="xalan:intersection(list[@name='abc'], list[@name='abc'])"/>
</test>
<test desc="selects nothing (abc, xyz)">
<xsl:copy-of select="xalan:intersection(list[@name='abc']/item, list[@name='xyz']/item)"/>
</test>
<test desc="selects nothing (abc, abc2)">
<xsl:copy-of select="xalan:intersection(list[@name='abc']/item, list[@name='abc2']/item)"/>
</test>
<test desc="selects a (abc, abc[1])">
<xsl:copy-of select="xalan:intersection(list[@name='abc']/item, list[@name='abc']/item[1])"/>
</test>
<test desc="selects a (abc[1], abc)">
<xsl:copy-of select="xalan:intersection(list[@name='abc']/item[1], list[@name='abc']/item)"/>
</test>
<test desc="selects a (abc[1], abc[1])">
<xsl:copy-of select="xalan:intersection(list[@name='abc']/item[1], list[@name='abc']/item[1])"/>
</test>
</out>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/test/tests/extensions/library/libraryNodeset01.xml
Index: libraryNodeset01.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryNodeset01.xsl
Index: libraryNodeset01.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<!-- FileName: xalanj2Nodeset01.xsl -->
<!-- Document: http://www.w3.org/TR/xslt -->
<!-- DocVersion: 19991116 -->
<!-- Creator: Shane Curcuru -->
<!-- Purpose: Nodeset sample from documentation -->
<xsl:template match="/">
<out>
<!-- Declare a variable, which is a result tree fragment -->
<xsl:variable name="rtf">
<docelem>
<elem1>
<elem1a>ELEMENT1A</elem1a>
<elem1b>ELEMENT1B</elem1b>
</elem1>
<elem2>
<elem2a>ELEMENT2A</elem2a>
</elem2>
</docelem>
</xsl:variable>
<!-- Use nodeset extension to treat the rtf as a nodeset -->
<xsl:for-each select="xalan:nodeset($rtf)/docelem//*">
<xsl:value-of select="name(.)"/><xsl:text>,</xsl:text>
</xsl:for-each>
</out>
</xsl:template>
</xsl:stylesheet>
1.1 xml-xalan/test/tests/extensions/library/libraryNodeset02.xml
Index: libraryNodeset02.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<ol>
<li>item1</li>
<li attrib="2">item2</li>
<li>item3</li>
<ol>
<li>subitem1</li>
<li attrib="2">subitem2</li>
<!-- now go deeper -->
<ol>
<li>subitem3</li>
</ol>
</ol>
<?a-pi some data?>
</ol>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryTokenize01.xml
Index: libraryTokenize01.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>
</doc>
1.1 xml-xalan/test/tests/extensions/library/libraryTokenize01.xsl
Index: libraryTokenize01.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<!-- Indent just for readability -->
<xsl:output indent="yes"/>
<!-- FileName: libraryTokenize01.xsl -->
<!-- Document: http://www.w3.org/TR/xslt -->
<!-- DocVersion: 19991116 -->
<!-- Creator: Shane Curcuru -->
<!-- Purpose: Basic test of tokenize() extension function -->
<xsl:template match="/">
<out>
<!-- Using copy-of then value-of on the same select= shows that
it's properly returning a node-set each time.
copy-of will print out all the nodes' text values in the set
value-of will only print the first nodes' text value
-->
<test desc="simple string, default separators">
<xsl:copy-of select="xalan:tokenize('one two	three')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:tokenize('one two	three')"/>
</test>
<test desc="simple string, colon separator">
<xsl:copy-of select="xalan:tokenize('one two:three', ':')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:tokenize('one two:three', ':')"/>
</test>
<test desc="blank string, default separators">
<xsl:copy-of select="xalan:tokenize('')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:tokenize('')"/>
</test>
<test desc="blank string, blank separators">
<xsl:copy-of select="xalan:tokenize('', '')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:tokenize('', '')"/>
</test>
<test desc="blank string, colon, x are separators">
<xsl:copy-of select="xalan:tokenize('', ':x')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:tokenize('', ':x')"/>
</test>
<test desc="all delimiter string, default separators">
<xsl:copy-of select="xalan:tokenize(' 	
')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:tokenize(' 	
')"/>
</test>
<test desc="all delimiter string, colon, x are separators">
<xsl:copy-of select="xalan:tokenize(':x::xx:', ':x')"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="xalan:tokenize(':x::xx:', ':x')"/>
</test>
<!-- Note: null string xalan:tokenize() is not a legal extension call -->
</out>
</xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org