sboag 99/12/13 00:14:42
Modified: src/org/apache/xalan/xslt KeyTable.java
Log:
Provide conversion of use attribute result to a string, if it is not a
node-set.
Revision Changes Path
1.4 +46 -22 xml-xalan/src/org/apache/xalan/xslt/KeyTable.java
Index: KeyTable.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/KeyTable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- KeyTable.java 1999/11/28 10:26:22 1.3
+++ KeyTable.java 1999/12/13 08:14:42 1.4
@@ -137,22 +137,35 @@
// Query from the node, according the the select pattern in the
// use attribute in xsl:key.
XObject xuse = kd.m_use.execute(xmlLiaison, testNode, nscontext);
-
- NodeList nl = xuse.nodeset();
- if(0 == nl.getLength())
- continue;
- // Use each node in the node list as a key value that we'll be
- // able to use to look up the given node.
- int nUseValues = nl.getLength();
- for(int k = 0; k < nUseValues; k++)
+ NodeList nl = null;
+ int nUseValues;
+ String exprResult = null;
+ if(xuse.getType() != xuse.CLASS_NODESET)
+ {
+ nUseValues = 1;
+ exprResult = xuse.str();
+ }
+ else
{
- Node useNode = nl.item(k);
+ nl = xuse.nodeset();
+ if(0 == nl.getLength())
+ continue;
+ // Use each node in the node list as a key value that we'll be
+ // able to use to look up the given node.
+ nUseValues = nl.getLength();
+ }
+ for(int k = 0; k < nUseValues; k++)
+ {
// Use getExpr to get the string value of the given node. I hope
// the string assumption is the right thing... I can't see how
// it could work any other way.
- String exprResult = XMLParserLiaisonDefault.getNodeData(useNode);
+ if(null != nl)
+ {
+ Node useNode = nl.item(k);
+ exprResult = XMLParserLiaisonDefault.getNodeData(useNode);
+ }
if(null == exprResult)
continue;
@@ -259,21 +272,32 @@
// use attribute in xsl:key.
XObject xuse = kd.m_use.execute(execContext, testNode,
nscontext);
- NodeList nl = xuse.nodeset();
- if(0 == nl.getLength())
- continue;
+ NodeList nl = null;
+ int nUseValues;
+ String exprResult = null;
+ if(xuse.getType() != xuse.CLASS_NODESET)
+ {
+ nUseValues = 1;
+ exprResult = xuse.str();
+ }
+ else
+ {
+ nl = xuse.nodeset();
+ if(0 == nl.getLength())
+ continue;
+
+ // Use each node in the node list as a key value that we'll be
+ // able to use to look up the given node.
+ nUseValues = nl.getLength();
+ }
- // Use each node in the node list as a key value that we'll be
- // able to use to look up the given node.
- int nUseValues = nl.getLength();
for(int k = 0; k < nUseValues; k++)
{
- Node useNode = nl.item(k);
-
- // Use getExpr to get the string value of the given node. I
hope
- // the string assumption is the right thing... I can't see how
- // it could work any other way.
- String exprResult =
XMLParserLiaisonDefault.getNodeData(useNode);
+ if(null != nl)
+ {
+ Node useNode = nl.item(k);
+ exprResult = XMLParserLiaisonDefault.getNodeData(useNode);
+ }
if(null == exprResult)
continue;