You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/05/10 22:49:25 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath/patterns FunctionPattern.java
sboag 01/05/10 13:49:24
Modified: java/src/org/apache/xalan/stree Tag: DTM_EXP
SourceTreeHandler.java StreeDTMManager.java
java/src/org/apache/xalan/templates Tag: DTM_EXP
ElemForEach.java ElemVariable.java
FuncDocument.java
java/src/org/apache/xalan/transformer Tag: DTM_EXP
NodeSortKey.java NodeSorter.java
QueuedStartElement.java ResultTreeHandler.java
TransformerImpl.java TreeWalker2Result.java
java/src/org/apache/xml/dtm/dom2dtm Tag: DTM_EXP
DOM2DTM.java
java/src/org/apache/xpath/axes Tag: DTM_EXP
ChildIterator.java ChildTestIterator.java
DescendantIterator.java LocPathIterator.java
UnionPathIterator.java
java/src/org/apache/xpath/functions Tag: DTM_EXP
FuncGenerateId.java FuncLast.java FuncPosition.java
java/src/org/apache/xpath/objects Tag: DTM_EXP XNumber.java
java/src/org/apache/xpath/patterns Tag: DTM_EXP
FunctionPattern.java
Log:
Passes the conformance suite now (at least on my machine, which hasn't
had the suite updated for a month). Many bug fixes. Anything that
requires DTM2DOM still won't work, such as extensions and the
TransformState stuff. DocumentManagement and launching DTMs
correctly is next on the agenda. Note that right now you have to
use -Dorg.apache.xml.dtm.DTMManager="org.apache.xalan.stree.StreeDTMManager".
DOMSources that hold generic DOMs won't work yet.
Revision Changes Path
No revision
No revision
1.35.2.4 +7 -5 xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java
Index: SourceTreeHandler.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/SourceTreeHandler.java,v
retrieving revision 1.35.2.3
retrieving revision 1.35.2.4
diff -u -r1.35.2.3 -r1.35.2.4
--- SourceTreeHandler.java 2001/05/07 13:14:47 1.35.2.3
+++ SourceTreeHandler.java 2001/05/10 20:48:05 1.35.2.4
@@ -113,9 +113,9 @@
* @param transformer The transformer this will use to transform a
* source tree into a result tree.
*/
- public SourceTreeHandler(TransformerImpl transformer)
+ public SourceTreeHandler(TransformerImpl transformer, String baseSystemID)
{
- this(transformer, false);
+ this(transformer, false, baseSystemID);
}
/**
@@ -125,7 +125,8 @@
* @param transformer The transformer this will use to transform a
* source tree into a result tree.
*/
- public SourceTreeHandler(TransformerImpl transformer, boolean doFragment)
+ public SourceTreeHandler(TransformerImpl transformer, boolean doFragment,
+ String baseSystemID)
{
// m_id = m_idCount++;
m_transformer = transformer;
@@ -145,7 +146,7 @@
{
m_root = new DocumentImpl(this);
}
- DOMSource ds = new DOMSource(m_root);
+ DOMSource ds = new DOMSource(m_root, baseSystemID);
dtm = mgr.getDTM(ds, false, transformer);
m_DTMroot = dtm.getDocument();
@@ -162,7 +163,8 @@
* @param transformer The transformer this will use to transform a
* source tree into a result tree.
*/
- public SourceTreeHandler(TransformerImpl transformer, DTMManager dtm, boolean doFragment)
+ public SourceTreeHandler(TransformerImpl transformer, DTMManager dtm,
+ boolean doFragment)
{
// m_id = m_idCount++;
m_transformer = transformer;
1.1.2.2 +22 -21 xml-xalan/java/src/org/apache/xalan/stree/Attic/StreeDTMManager.java
Index: StreeDTMManager.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/stree/Attic/StreeDTMManager.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- StreeDTMManager.java 2001/05/07 13:11:21 1.1.2.1
+++ StreeDTMManager.java 2001/05/10 20:48:07 1.1.2.2
@@ -132,8 +132,29 @@
SourceTreeHandler sth = new SourceTreeHandler();
sth.setUseMultiThreading(false);
+ // transformer.setIsTransformDone(false);
+ InputSource xmlSource = SAXSource.sourceToInputSource(source);
+
+ String urlOfSource = xmlSource.getSystemId();
+
+ if (null != urlOfSource)
+ {
+ try
+ {
+ urlOfSource = SystemIDResolver.getAbsoluteURI(urlOfSource);
+ }
+ catch (Exception e)
+ {
+
+ // %REVIEW% Is there a better way to send a warning?
+ System.err.println("Can not absolutize URL: " + urlOfSource);
+ }
+
+ xmlSource.setSystemId(urlOfSource);
+ }
+
int documentID = m_dtms.size() << 20;
- DOMSource ds = new DOMSource(sth.getRoot());
+ DOMSource ds = new DOMSource(sth.getRoot(), xmlSource.getSystemId());
DTM dtm = new DOM2DTM(this, ds, documentID, whiteSpaceFilter);
int doc = sth.getDTMRoot();
m_dtms.add(dtm);
@@ -182,31 +203,11 @@
// stm.putDocumentInCache(doc, source);
// transformer.setXMLSource(source);
- // transformer.setIsTransformDone(false);
- InputSource xmlSource = SAXSource.sourceToInputSource(source);
-
if (null == xmlSource)
{
throw new DTMException("Not supported: " + source);
}
- String urlOfSource = xmlSource.getSystemId();
-
- if (null != urlOfSource)
- {
- try
- {
- urlOfSource = SystemIDResolver.getAbsoluteURI(urlOfSource);
- }
- catch (Exception e)
- {
-
- // %REVIEW% Is there a better way to send a warning?
- System.err.println("Can not absolutize URL: " + urlOfSource);
- }
-
- xmlSource.setSystemId(urlOfSource);
- }
try
{
No revision
No revision
1.20.2.3 +1 -0 xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java
Index: ElemForEach.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java,v
retrieving revision 1.20.2.2
retrieving revision 1.20.2.3
diff -u -r1.20.2.2 -r1.20.2.3
--- ElemForEach.java 2001/05/06 02:09:28 1.20.2.2
+++ ElemForEach.java 2001/05/10 20:48:12 1.20.2.3
@@ -403,6 +403,7 @@
while (DTM.NULL != (child = sourceNodes.nextNode()))
{
+ // System.out.println("child: "+child);
DTM dtm = xctxt.getDTM(child);
if (needToFindTemplate)
{
1.10.2.3 +23 -17 xml-xalan/java/src/org/apache/xalan/templates/ElemVariable.java
Index: ElemVariable.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemVariable.java,v
retrieving revision 1.10.2.2
retrieving revision 1.10.2.3
diff -u -r1.10.2.2 -r1.10.2.3
--- ElemVariable.java 2001/05/07 13:14:56 1.10.2.2
+++ ElemVariable.java 2001/05/10 20:48:14 1.10.2.3
@@ -274,27 +274,33 @@
{
XObject var;
+ XPathContext xctxt = transformer.getXPathContext();
+ xctxt.pushCurrentNode(sourceNode);
- if (null != m_selectPattern)
+ try
{
- XPathContext xctxt = transformer.getXPathContext();
-
- var = m_selectPattern.execute(xctxt, sourceNode, this);
- if(TransformerImpl.S_DEBUG)
- transformer.getTraceManager().fireSelectedEvent(sourceNode, this,
- "select", m_selectPattern, var);
- }
- else if (null == getFirstChildElem())
- {
- var = XString.EMPTYSTRING;
+ if (null != m_selectPattern)
+ {
+ var = m_selectPattern.execute(xctxt, sourceNode, this);
+ if(TransformerImpl.S_DEBUG)
+ transformer.getTraceManager().fireSelectedEvent(sourceNode, this,
+ "select", m_selectPattern, var);
+ }
+ else if (null == getFirstChildElem())
+ {
+ var = XString.EMPTYSTRING;
+ }
+ else
+ {
+
+ // Use result tree fragment
+ int df = transformer.transformToRTF(this);
+ var = new XRTreeFrag(df, xctxt);
+ }
}
- else
+ finally
{
-
- // Use result tree fragment
- int df = transformer.transformToRTF(this);
- XPathContext xctxt = transformer.getXPathContext();
- var = new XRTreeFrag(df, xctxt);
+ xctxt.popCurrentNode();
}
return var;
1.19.2.4 +11 -9 xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java
Index: FuncDocument.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/FuncDocument.java,v
retrieving revision 1.19.2.3
retrieving revision 1.19.2.4
diff -u -r1.19.2.3 -r1.19.2.4
--- FuncDocument.java 2001/05/07 13:14:57 1.19.2.3
+++ FuncDocument.java 2001/05/10 20:48:15 1.19.2.4
@@ -150,16 +150,18 @@
warn(xctxt, XSLTErrorResources.WG_EMPTY_SECOND_ARG, null);
DTM baseDTM = xctxt.getDTM(baseNode);
- int baseDoc = baseDTM.getDocument();
+ base = baseDTM.getDocumentBaseURI(baseNode);
- if (baseDoc == DTM.NULL /* || baseDoc instanceof Stylesheet %TBD% What to do?? */)
- {
-
- // base = ((Stylesheet)baseDoc).getBaseIdentifier();
- base = xctxt.getNamespaceContext().getBaseIdentifier();
- }
- else
- base = xctxt.getSourceTreeManager().findURIFromDoc(baseDoc);
+// int baseDoc = baseDTM.getDocument();
+//
+// if (baseDoc == DTM.NULL /* || baseDoc instanceof Stylesheet %TBD% What to do?? */)
+// {
+//
+// // base = ((Stylesheet)baseDoc).getBaseIdentifier();
+// base = xctxt.getNamespaceContext().getBaseIdentifier();
+// }
+// else
+// base = xctxt.getSourceTreeManager().findURIFromDoc(baseDoc);
}
else
{
No revision
No revision
1.7.2.1 +3 -1 xml-xalan/java/src/org/apache/xalan/transformer/NodeSortKey.java
Index: NodeSortKey.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/NodeSortKey.java,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -r1.7 -r1.7.2.1
--- NodeSortKey.java 2001/01/26 01:26:59 1.7
+++ NodeSortKey.java 2001/05/10 20:48:21 1.7.2.1
@@ -110,7 +110,9 @@
* @throws javax.xml.transform.TransformerException
*/
NodeSortKey(
- TransformerImpl transformer, XPath selectPat, boolean treatAsNumbers, boolean descending, String langValue, boolean caseOrderUpper, org.apache.xml.utils.PrefixResolver namespaceContext)
+ TransformerImpl transformer, XPath selectPat, boolean treatAsNumbers,
+ boolean descending, String langValue, boolean caseOrderUpper,
+ org.apache.xml.utils.PrefixResolver namespaceContext)
throws javax.xml.transform.TransformerException
{
1.9.2.4 +7 -2 xml-xalan/java/src/org/apache/xalan/transformer/NodeSorter.java
Index: NodeSorter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/NodeSorter.java,v
retrieving revision 1.9.2.3
retrieving revision 1.9.2.4
diff -u -r1.9.2.3 -r1.9.2.4
--- NodeSorter.java 2001/05/07 13:15:05 1.9.2.3
+++ NodeSorter.java 2001/05/10 20:48:23 1.9.2.4
@@ -147,6 +147,7 @@
{
v.setItem(((NodeCompareElem) nodes.elementAt(i)).m_node, i);
}
+ v.setCurrentPos(0);
// old code...
//NodeVector scratchVector = new NodeVector(n);
@@ -552,10 +553,14 @@
if (r.getType() == XObject.CLASS_NODESET)
{
- DTMIterator ni = r.nodeset();
+ // %REVIEW%
+ DTMIterator ni = (DTMIterator)r.object();
+ int current = ni.getCurrentNode();
+ if(DTM.NULL == current)
+ current = ni.nextNode();
// if (ni instanceof ContextNodeList) // %REVIEW%
- tryNextKey = (ni.getCurrentNode() != DTM.NULL);
+ tryNextKey = (DTM.NULL != current);
// else abdicate... should never happen, but... -sb
}
1.9.2.2 +1 -0 xml-xalan/java/src/org/apache/xalan/transformer/QueuedStartElement.java
Index: QueuedStartElement.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/QueuedStartElement.java,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -u -r1.9.2.1 -r1.9.2.2
--- QueuedStartElement.java 2001/04/10 18:45:03 1.9.2.1
+++ QueuedStartElement.java 2001/05/10 20:48:24 1.9.2.2
@@ -304,6 +304,7 @@
*/
void setNSDeclsHaveBeenAdded(boolean b)
{
+ // System.out.println("setNSDeclsHaveBeenAdded: "+b);
m_nsDeclsHaveBeenAdded = b;
}
1.37.2.4 +56 -8 xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java
Index: ResultTreeHandler.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/ResultTreeHandler.java,v
retrieving revision 1.37.2.3
retrieving revision 1.37.2.4
diff -u -r1.37.2.3 -r1.37.2.4
--- ResultTreeHandler.java 2001/05/07 13:15:07 1.37.2.3
+++ ResultTreeHandler.java 2001/05/10 20:48:25 1.37.2.4
@@ -234,10 +234,10 @@
+ qse.getLocalName());
System.out.println("ResultTreeHandler#startElement: " + ns + "#" + localName);
- if(null == ns)
- {
- (new RuntimeException(localName+" has a null namespace!")).printStackTrace();
- }
+// if(null == ns)
+// {
+// (new RuntimeException(localName+" has a null namespace!")).printStackTrace();
+// }
}
checkForSerializerSwitch(ns, localName);
@@ -278,7 +278,7 @@
System.out.println("ResultTreeHandler#endElement: " + ns + "#" + localName);
}
-
+
flushPending(EVT_ENDELEMENT);
m_contentHandler.endElement(ns, localName, name);
@@ -728,6 +728,23 @@
* wrapping another exception.
*/
public void skippedEntity(String name) throws org.xml.sax.SAXException{}
+
+ /**
+ * Set whether Namespace declarations have been added to
+ * this element
+ *
+ *
+ * @param b Flag indicating whether Namespace declarations
+ * have been added to this element
+ */
+ public void setNSDeclsHaveBeenAdded(boolean b)
+ {
+ QueuedStartElement qe = getQueuedElem();
+ if (null != qe)
+ {
+ qe.setNSDeclsHaveBeenAdded(b);
+ }
+ }
/**
* Flush the pending element.
@@ -844,7 +861,7 @@
*
* @throws org.xml.sax.SAXException
*/
- void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException
+ public void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException
{
if (ns != null && ns.length() > 0)
@@ -857,8 +874,39 @@
{
String foundURI = m_nsSupport.getURI(prefix);
- if ((null == foundURI) ||!foundURI.equals(ns))
+ if ((null == foundURI) || !foundURI.equals(ns))
+ {
+
startPrefixMapping(prefix, ns, false);
+ }
+ }
+ }
+ }
+
+ /**
+ * This function checks to make sure a given prefix is really
+ * declared. It might not be, because it may be an excluded prefix.
+ * If it's not, it still needs to be declared at this point.
+ * TODO: This needs to be done at an earlier stage in the game... -sb
+ *
+ * @param ns Namespace URI of the element
+ * @param rawName Raw name of element (with prefix)
+ *
+ * @throws org.xml.sax.SAXException
+ */
+ public void ensureNamespaceDeclDeclared(DTM dtm, int namespace) throws org.xml.sax.SAXException
+ {
+ String uri = dtm.getNodeValue(namespace);
+ String prefix = dtm.getPrefix(namespace);
+
+ if ((uri != null && uri.length() > 0) && (null != prefix))
+ {
+ String foundURI = m_nsSupport.getURI(prefix);
+
+ if ((null == foundURI) || !foundURI.equals(uri))
+ {
+
+ startPrefixMapping(prefix, uri, false);
}
}
}
@@ -935,7 +983,7 @@
* Add the attributes that have been declared to the attribute list.
* (Seems like I shouldn't have to do this...)
*/
- protected void addNSDeclsToAttrs()
+ public void addNSDeclsToAttrs()
{
Enumeration prefixes = m_nsSupport.getDeclaredPrefixes();
1.90.2.4 +2 -2 xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TransformerImpl.java,v
retrieving revision 1.90.2.3
retrieving revision 1.90.2.4
diff -u -r1.90.2.3 -r1.90.2.4
--- TransformerImpl.java 2001/05/07 13:15:09 1.90.2.3
+++ TransformerImpl.java 2001/05/10 20:48:26 1.90.2.4
@@ -1320,7 +1320,7 @@
if (null == m_inputContentHandler)
{
- m_inputContentHandler = new SourceTreeHandler(this, doDocFrag);
+ m_inputContentHandler = new SourceTreeHandler(this, doDocFrag, m_urlOfSource);
((SourceTreeHandler)m_inputContentHandler).setUseMultiThreading(true);
}
@@ -1811,7 +1811,7 @@
int resultFragment = DTM.NULL;
// %TODO% Use SAX2DTM here (I think)
- rtfHandler = new SourceTreeHandler(this, true);
+ rtfHandler = new SourceTreeHandler(this, true, templateParent.getBaseIdentifier());
((SourceTreeHandler)rtfHandler).setUseMultiThreading(false);
((SourceTreeHandler)rtfHandler).setShouldTransformAtEnd(false);
// Create a ResultTreeFrag object.
1.9.2.3 +18 -10 xml-xalan/java/src/org/apache/xalan/transformer/TreeWalker2Result.java
Index: TreeWalker2Result.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/transformer/TreeWalker2Result.java,v
retrieving revision 1.9.2.2
retrieving revision 1.9.2.3
diff -u -r1.9.2.2 -r1.9.2.3
--- TreeWalker2Result.java 2001/05/07 13:15:10 1.9.2.2
+++ TreeWalker2Result.java 2001/05/10 20:48:28 1.9.2.3
@@ -133,22 +133,30 @@
String elemName = m_dtm.getNodeName(node);
String localName = m_dtm.getLocalName(node);
String namespace = m_dtm.getNamespaceURI(node);
-
+
m_handler.startElement(namespace, localName, elemName, null);
if (DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
{
- for (int attr = m_dtm.getFirstAttribute(node);
- DTM.NULL != attr; attr = m_dtm.getNextAttribute(node))
+ boolean hasNSDecls = false;
+ DTM dtm = m_dtm;
+ for (int ns = dtm.getFirstNamespaceNode(node, true);
+ DTM.NULL != ns; ns = dtm.getNextNamespaceNode(node, ns, true))
{
- String name = m_dtm.getNodeName(attr);
- String value = m_dtm.getStringValue(attr);
-
- m_handler.addAttribute(m_dtm.getNamespaceURI(attr),
- m_dtm.getLocalName(attr), name,
- "CDATA", value);
-
+ m_handler.ensureNamespaceDeclDeclared(dtm, ns);
+ }
+
+ if(hasNSDecls)
+ {
+ m_handler.addNSDeclsToAttrs();
+ }
+
+ for (int attr = dtm.getFirstAttribute(node);
+ DTM.NULL != attr; attr = dtm.getNextAttribute(attr))
+ {
+ m_handler.addAttribute(attr);
}
+
}
}
else
No revision
No revision
1.1.2.9 +46 -16 xml-xalan/java/src/org/apache/xml/dtm/dom2dtm/Attic/DOM2DTM.java
Index: DOM2DTM.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/dom2dtm/Attic/DOM2DTM.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- DOM2DTM.java 2001/05/08 01:12:49 1.1.2.8
+++ DOM2DTM.java 2001/05/10 20:48:41 1.1.2.9
@@ -402,6 +402,13 @@
nextNode = pos.getNextSibling();
+ if(Node.ELEMENT_NODE == pos.getNodeType())
+ {
+ // I think this only has to be popped here, and not at getParent,
+ // oddly enough at first glance.
+ popShouldStripWhitespace();
+ }
+
// %TBD% Text node coalition.
if((null != nextNode) && (null != m_wsfilter) && getShouldStripWhitespace())
{
@@ -416,13 +423,7 @@
}
}
}
- if(Node.ELEMENT_NODE == pos.getNodeType())
- {
- // I think this only has to be popped here, and not at getParent,
- // oddly enough at first glance.
- popShouldStripWhitespace();
- }
-
+
if (null == nextNode)
{
m_info.setElementAt(DTM.NULL, posInfo + OFFSET_NEXTSIBLING);
@@ -439,6 +440,7 @@
break;
}
}
+
} // end while (null == nextNode) [for next sibling, parent]
@@ -541,7 +543,7 @@
for (int i = 0; i < len; i++)
{
- if (m_nodes == node)
+ if (m_nodes.elementAt(i) == node)
return i | m_dtmIdent;
}
}
@@ -707,7 +709,7 @@
}
else if (DTM.NAMESPACE_NODE != type)
{
- // ignore
+ break;
}
}
}
@@ -951,7 +953,7 @@
/**
* Given a namespace handle, advance to the next namespace.
*
- * @param baseHandle handle to original node from where the first child
+ * @param baseHandle handle to original node from where the first namespace
* was relative to (needed to return nodes in document order).
* @param namespaceHandle handle to node which must be of type
* NAMESPACE_NODE.
@@ -1753,9 +1755,33 @@
Document doc = (m_root.getNodeType() == Node.DOCUMENT_NODE)
? (Document) m_root : m_root.getOwnerDocument();
-
- return (null != doc)
- ? getHandleFromNode(doc.getElementById(elementId)) : DTM.NULL;
+
+ if(null != doc)
+ {
+ Node elem = doc.getElementById(elementId);
+ if(null != elem)
+ {
+ int elemHandle = getHandleFromNode(elem);
+
+ if(DTM.NULL == elemHandle)
+ {
+ int identity = m_nodes.size()-1;
+ while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
+ {
+ Node node = getNode(identity);
+ if(node == elem)
+ {
+ elemHandle = getHandleFromNode(elem);
+ break;
+ }
+ }
+ }
+
+ return elemHandle;
+ }
+
+ }
+ return DTM.NULL;
}
/**
@@ -1978,7 +2004,7 @@
{
int type = getNodeType(nodeHandle);
Node node = getNode(nodeHandle);
- dispatchNodeData(node, ch);
+ dispatchNodeData(node, ch, 0);
}
/**
@@ -1998,7 +2024,9 @@
* @param buf FastStringBuffer into which the contents of the text
* nodes are to be concatenated.
*/
- protected static void dispatchNodeData(Node node, org.xml.sax.ContentHandler ch)
+ protected static void dispatchNodeData(Node node,
+ org.xml.sax.ContentHandler ch,
+ int depth)
throws org.xml.sax.SAXException
{
@@ -2011,12 +2039,14 @@
for (Node child = node.getFirstChild(); null != child;
child = child.getNextSibling())
{
- dispatchNodeData(child, ch);
+ dispatchNodeData(child, ch, depth+1);
}
}
break;
case Node.PROCESSING_INSTRUCTION_NODE : // %REVIEW%
case Node.COMMENT_NODE :
+ if(0 != depth)
+ break;
case Node.TEXT_NODE :
case Node.CDATA_SECTION_NODE :
case Node.ATTRIBUTE_NODE :
No revision
No revision
1.6.2.2 +7 -4 xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java
Index: ChildIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ChildIterator.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- ChildIterator.java 2001/04/10 18:45:15 1.6.2.1
+++ ChildIterator.java 2001/05/10 20:48:46 1.6.2.2
@@ -106,12 +106,15 @@
// If the cache is on, and the node has already been found, then
// just return from the list.
+ // If the cache is on, and the node has already been found, then
+ // just return from the list.
if ((null != m_cachedNodes)
- && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+ && (m_next < m_cachedNodes.size()))
{
- int next = m_cachedNodes.nextNode();
-
- this.setCurrentPos(m_cachedNodes.getCurrentPos());
+ int next = m_cachedNodes.elementAt(m_next);
+
+ incrementNextPosition();
+ m_currentContextNode = next;
return next;
}
1.8.2.2 +7 -4 xml-xalan/java/src/org/apache/xpath/axes/ChildTestIterator.java
Index: ChildTestIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/ChildTestIterator.java,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -r1.8.2.1 -r1.8.2.2
--- ChildTestIterator.java 2001/04/10 18:45:15 1.8.2.1
+++ ChildTestIterator.java 2001/05/10 20:48:48 1.8.2.2
@@ -153,12 +153,15 @@
// If the cache is on, and the node has already been found, then
// just return from the list.
+ // If the cache is on, and the node has already been found, then
+ // just return from the list.
if ((null != m_cachedNodes)
- && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+ && (m_next < m_cachedNodes.size()))
{
- int next = m_cachedNodes.nextNode();
-
- this.setCurrentPos(m_cachedNodes.getCurrentPos());
+ int next = m_cachedNodes.elementAt(m_next);
+
+ incrementNextPosition();
+ m_currentContextNode = next;
return next;
}
1.8.2.4 +7 -4 xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java
Index: DescendantIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/DescendantIterator.java,v
retrieving revision 1.8.2.3
retrieving revision 1.8.2.4
diff -u -r1.8.2.3 -r1.8.2.4
--- DescendantIterator.java 2001/05/07 13:15:46 1.8.2.3
+++ DescendantIterator.java 2001/05/10 20:48:50 1.8.2.4
@@ -185,12 +185,15 @@
// If the cache is on, and the node has already been found, then
// just return from the list.
+ // If the cache is on, and the node has already been found, then
+ // just return from the list.
if ((null != m_cachedNodes)
- && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+ && (m_next < m_cachedNodes.size()))
{
- int next = m_cachedNodes.nextNode();
-
- this.setCurrentPos(m_cachedNodes.getCurrentPos());
+ int next = m_cachedNodes.elementAt(m_next);
+
+ incrementNextPosition();
+ m_currentContextNode = next;
return next;
}
1.24.2.4 +13 -7 xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java
Index: LocPathIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java,v
retrieving revision 1.24.2.3
retrieving revision 1.24.2.4
diff -u -r1.24.2.3 -r1.24.2.4
--- LocPathIterator.java 2001/05/07 13:15:47 1.24.2.3
+++ LocPathIterator.java 2001/05/10 20:48:52 1.24.2.4
@@ -748,11 +748,12 @@
// If the cache is on, and the node has already been found, then
// just return from the list.
if ((null != m_cachedNodes)
- && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+ && (m_next < m_cachedNodes.size()))
{
- int next = m_cachedNodes.nextNode();
-
- this.setCurrentPos(m_cachedNodes.getCurrentPos());
+ int next = m_cachedNodes.elementAt(m_next);
+
+ incrementNextPosition();
+ m_currentContextNode = next;
return next;
}
@@ -1064,14 +1065,19 @@
try
{
- clone = (LocPathIterator) clone();
+ // %REVIEW% %OPT%
+ if(0 == pos && m_currentContextNode != DTM.NULL)
+ clone = (LocPathIterator) cloneWithReset();
+ else
+ clone = (LocPathIterator) clone();
}
catch (CloneNotSupportedException cnse)
{
return -1;
}
-
- clone.setPredicateCount(clone.getPredicateCount() - 1);
+ // %REVIEW% Commented this out, as it was messing up pos68 test. count-1?
+ // System.out.println("clone.getPredicateCount(): "+clone.getPredicateCount());
+ // clone.setPredicateCount(clone.getPredicateCount() - 1);
int next;
1.15.2.4 +14 -2 xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java
Index: UnionPathIterator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java,v
retrieving revision 1.15.2.3
retrieving revision 1.15.2.4
diff -u -r1.15.2.3 -r1.15.2.4
--- UnionPathIterator.java 2001/05/07 13:15:49 1.15.2.3
+++ UnionPathIterator.java 2001/05/10 20:48:54 1.15.2.4
@@ -538,12 +538,24 @@
public int nextNode()
{
+// // If the cache is on, and the node has already been found, then
+// // just return from the list.
+// if ((null != m_cachedNodes)
+// && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+// {
+// return m_cachedNodes.nextNode();
+// }
// If the cache is on, and the node has already been found, then
// just return from the list.
if ((null != m_cachedNodes)
- && (m_cachedNodes.getCurrentPos() < m_cachedNodes.size()))
+ && (m_next < m_cachedNodes.size()))
{
- return m_cachedNodes.nextNode();
+ int next = m_cachedNodes.elementAt(m_next);
+
+ m_next++;
+ m_currentContextNode = next;
+
+ return next;
}
if (m_foundLast)
No revision
No revision
1.4.2.2 +1 -1 xml-xalan/java/src/org/apache/xpath/functions/FuncGenerateId.java
Index: FuncGenerateId.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncGenerateId.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -r1.4.2.1 -r1.4.2.2
--- FuncGenerateId.java 2001/04/10 18:45:29 1.4.2.1
+++ FuncGenerateId.java 2001/05/10 20:49:05 1.4.2.2
@@ -88,7 +88,7 @@
int which = getArg0AsNode(xctxt);
if (DTM.NULL != which)
- return new XString(String.valueOf(which));
+ return new XString("N" + Integer.toHexString(which+1).toUpperCase());
else
return XString.EMPTYSTRING;
}
1.6.2.3 +3 -2 xml-xalan/java/src/org/apache/xpath/functions/FuncLast.java
Index: FuncLast.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncLast.java,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.3
diff -u -r1.6.2.2 -r1.6.2.3
--- FuncLast.java 2001/05/06 02:09:54 1.6.2.2
+++ FuncLast.java 2001/05/10 20:49:08 1.6.2.3
@@ -100,8 +100,9 @@
return iter.getLastPos(xctxt);
DTMIterator cnl = xctxt.getContextNodeList();
-
- return cnl.getLength();
+ int count = cnl.getLength();
+ // System.out.println("count: "+count);
+ return count;
}
/**
1.4.2.2 +31 -2 xml-xalan/java/src/org/apache/xpath/functions/FuncPosition.java
Index: FuncPosition.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncPosition.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -r1.4.2.1 -r1.4.2.2
--- FuncPosition.java 2001/04/10 18:45:31 1.4.2.1
+++ FuncPosition.java 2001/05/10 20:49:09 1.4.2.2
@@ -105,7 +105,34 @@
if (null != cnl)
{
-
+ int n = cnl.getCurrentNode();
+ if(n == DTM.NULL)
+ {
+ if(cnl.getCurrentPos() == 0)
+ return 0;
+
+ // Then I think we're in a sort. See sort21.xsl. So the iterator has
+ // already been spent, and is not on the node we're processing.
+ // It's highly possible that this is an issue for other context-list
+ // functions. Shouldn't be a problem for last(), and it shouldn't be
+ // a problem for current().
+ try
+ {
+ cnl = cnl.cloneWithReset();
+ }
+ catch(CloneNotSupportedException cnse)
+ {
+ throw new org.apache.xml.utils.WrappedRuntimeException(cnse);
+ }
+ int currentNode = xctxt.getContextNode();
+ // System.out.println("currentNode: "+currentNode);
+ while(DTM.NULL != (n = cnl.nextNode()))
+ {
+ if(n == currentNode)
+ break;
+ }
+ }
+ // System.out.println("n: "+n);
// System.out.println("FuncPosition- cnl.getCurrentPos(): "+cnl.getCurrentPos());
return cnl.getCurrentPos();
}
@@ -124,6 +151,8 @@
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{
- return new XNumber((double) getPositionInContextNodeList(xctxt));
+ double pos = (double) getPositionInContextNodeList(xctxt);
+
+ return new XNumber(pos);
}
}
No revision
No revision
1.8.2.2 +173 -105 xml-xalan/java/src/org/apache/xpath/objects/XNumber.java
Index: XNumber.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/objects/XNumber.java,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -r1.8.2.1 -r1.8.2.2
--- XNumber.java 2001/04/10 18:45:43 1.8.2.1
+++ XNumber.java 2001/05/10 20:49:16 1.8.2.2
@@ -125,13 +125,162 @@
return (Double.isNaN(m_val) || (m_val == 0.0)) ? false : true;
}
+// /**
+// * Cast result object to a string.
+// *
+// * @return "NaN" if the number is NaN, Infinity or -Infinity if
+// * the number is infinite or the string value of the number.
+// */
+// private static final int PRECISION = 16;
+// public String str()
+// {
+//
+// if (Double.isNaN(m_val))
+// {
+// return "NaN";
+// }
+// else if (Double.isInfinite(m_val))
+// {
+// if (m_val > 0)
+// return "Infinity";
+// else
+// return "-Infinity";
+// }
+//
+// long longVal = (long)m_val;
+// if ((double)longVal == m_val)
+// return Long.toString(longVal);
+//
+//
+// String s = Double.toString(m_val);
+// int len = s.length();
+//
+// if (s.charAt(len - 2) == '.' && s.charAt(len - 1) == '0')
+// {
+// return s.substring(0, len - 2);
+// }
+//
+// int exp = 0;
+// int e = s.indexOf('E');
+// if (e != -1)
+// {
+// exp = Integer.parseInt(s.substring(e + 1));
+// s = s.substring(0,e);
+// len = e;
+// }
+//
+// // Calculate Significant Digits:
+// // look from start of string for first digit
+// // look from end for last digit
+// // significant digits = end - start + (0 or 1 depending on decimal location)
+//
+// int decimalPos = -1;
+// int start = (s.charAt(0) == '-') ? 1 : 0;
+// findStart: for( ; start < len; start++ )
+// {
+// switch (s.charAt(start))
+// {
+// case '0':
+// break;
+// case '.':
+// decimalPos = start;
+// break;
+// default:
+// break findStart;
+// }
+// }
+// int end = s.length() - 1;
+// findEnd: for( ; end > start; end-- )
+// {
+// switch (s.charAt(end))
+// {
+// case '0':
+// break;
+// case '.':
+// decimalPos = end;
+// break;
+// default:
+// break findEnd;
+// }
+// }
+//
+// int sigDig = end - start;
+//
+// // clarify decimal location if it has not yet been found
+// if (decimalPos == -1)
+// decimalPos = s.indexOf('.');
+//
+// // if decimal is not between start and end, add one to sigDig
+// if (decimalPos < start || decimalPos > end)
+// ++sigDig;
+//
+// // reduce significant digits to PRECISION if necessary
+// if (sigDig > PRECISION)
+// {
+// // re-scale BigDecimal in order to get significant digits = PRECISION
+// BigDecimal num = new BigDecimal(s);
+// int newScale = num.scale() - (sigDig - PRECISION);
+// if (newScale < 0)
+// newScale = 0;
+// s = num.setScale(newScale, BigDecimal.ROUND_HALF_UP).toString();
+//
+// // remove trailing '0's; keep track of decimalPos
+// int truncatePoint = s.length();
+// while (s.charAt(--truncatePoint) == '0')
+// ;
+//
+// if (s.charAt(truncatePoint) == '.')
+// {
+// decimalPos = truncatePoint;
+// }
+// else
+// {
+// decimalPos = s.indexOf('.');
+// truncatePoint += 1;
+// }
+//
+// s = s.substring(0, truncatePoint);
+// len = s.length();
+// }
+//
+// // Account for exponent by adding zeros as needed
+// // and moving the decimal place
+//
+// if (exp == 0)
+// return s;
+//
+// start = 0;
+// String sign;
+// if (s.charAt(0) == '-')
+// {
+// sign = "-";
+// start++;
+// }
+// else
+// sign = "";
+//
+// String wholePart = s.substring(start, decimalPos);
+// String decimalPart = s.substring(decimalPos + 1);
+//
+// // get the number of digits right of the decimal
+// int decimalLen = decimalPart.length();
+//
+// if (exp >= decimalLen)
+// return sign + wholePart + decimalPart + zeros(exp - decimalLen);
+//
+// if (exp > 0)
+// return sign + wholePart + decimalPart.substring(0, exp) + "."
+// + decimalPart.substring(exp);
+//
+// return sign + "0." + zeros(-1 - exp) + wholePart + decimalPart;
+// }
+
/**
* Cast result object to a string.
*
* @return "NaN" if the number is NaN, Infinity or -Infinity if
* the number is infinite or the string value of the number.
*/
- private static final int PRECISION = 16;
public String str()
{
@@ -146,134 +295,53 @@
else
return "-Infinity";
}
-
- long longVal = (long)m_val;
- if ((double)longVal == m_val)
- return Long.toString(longVal);
-
- String s = Double.toString(m_val);
+ double num = m_val;
+ String s = Double.toString(num);
int len = s.length();
if (s.charAt(len - 2) == '.' && s.charAt(len - 1) == '0')
- {
- return s.substring(0, len - 2);
- }
-
- int exp = 0;
- int e = s.indexOf('E');
- if (e != -1)
- {
- exp = Integer.parseInt(s.substring(e + 1));
- s = s.substring(0,e);
- len = e;
- }
-
- // Calculate Significant Digits:
- // look from start of string for first digit
- // look from end for last digit
- // significant digits = end - start + (0 or 1 depending on decimal location)
-
- int decimalPos = -1;
- int start = (s.charAt(0) == '-') ? 1 : 0;
- findStart: for( ; start < len; start++ )
- {
- switch (s.charAt(start))
- {
- case '0':
- break;
- case '.':
- decimalPos = start;
- break;
- default:
- break findStart;
- }
- }
- int end = s.length() - 1;
- findEnd: for( ; end > start; end-- )
{
- switch (s.charAt(end))
- {
- case '0':
- break;
- case '.':
- decimalPos = end;
- break;
- default:
- break findEnd;
- }
- }
-
- int sigDig = end - start;
+ s = s.substring(0, len - 2);
- // clarify decimal location if it has not yet been found
- if (decimalPos == -1)
- decimalPos = s.indexOf('.');
-
- // if decimal is not between start and end, add one to sigDig
- if (decimalPos < start || decimalPos > end)
- ++sigDig;
-
- // reduce significant digits to PRECISION if necessary
- if (sigDig > PRECISION)
- {
- // re-scale BigDecimal in order to get significant digits = PRECISION
- BigDecimal num = new BigDecimal(s);
- int newScale = num.scale() - (sigDig - PRECISION);
- if (newScale < 0)
- newScale = 0;
- s = num.setScale(newScale, BigDecimal.ROUND_HALF_UP).toString();
-
- // remove trailing '0's; keep track of decimalPos
- int truncatePoint = s.length();
- while (s.charAt(--truncatePoint) == '0')
- ;
-
- if (s.charAt(truncatePoint) == '.')
- {
- decimalPos = truncatePoint;
- }
- else
- {
- decimalPos = s.indexOf('.');
- truncatePoint += 1;
- }
+ if (s.equals("-0"))
+ return "0";
- s = s.substring(0, truncatePoint);
- len = s.length();
+ return s;
}
- // Account for exponent by adding zeros as needed
- // and moving the decimal place
+ int e = s.indexOf('E');
- if (exp == 0)
- return s;
+ if (e < 0)
+ return s;
- start = 0;
+ int exp = Integer.parseInt(s.substring(e + 1));
String sign;
+
if (s.charAt(0) == '-')
{
sign = "-";
- start++;
+ s = s.substring(1);
+
+ --e;
}
else
sign = "";
- String wholePart = s.substring(start, decimalPos);
- String decimalPart = s.substring(decimalPos + 1);
+ int nDigits = e - 2;
- // get the number of digits right of the decimal
- int decimalLen = decimalPart.length();
+ if (exp >= nDigits)
+ return sign + s.substring(0, 1) + s.substring(2, e)
+ + zeros(exp - nDigits);
- if (exp >= decimalLen)
- return sign + wholePart + decimalPart + zeros(exp - decimalLen);
-
if (exp > 0)
- return sign + wholePart + decimalPart.substring(0, exp) + "."
- + decimalPart.substring(exp);
+ return sign + s.substring(0, 1) + s.substring(2, 2 + exp) + "."
+ + s.substring(2 + exp, e);
- return sign + "0." + zeros(-1 - exp) + wholePart + decimalPart;
+ return sign + "0." + zeros(-1 - exp) + s.substring(0, 1)
+ + s.substring(2, e);
}
+
/**
* Return a string of '0' of the given length
No revision
No revision
1.7.2.3 +1 -1 xml-xalan/java/src/org/apache/xpath/patterns/FunctionPattern.java
Index: FunctionPattern.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/patterns/FunctionPattern.java,v
retrieving revision 1.7.2.2
retrieving revision 1.7.2.3
diff -u -r1.7.2.2 -r1.7.2.3
--- FunctionPattern.java 2001/05/07 13:16:11 1.7.2.2
+++ FunctionPattern.java 2001/05/10 20:49:21 1.7.2.3
@@ -136,7 +136,7 @@
while (DTM.NULL != (n = nl.nextNode()))
{
- score = (context == context) ? SCORE_OTHER : SCORE_NONE;
+ score = (n == context) ? SCORE_OTHER : SCORE_NONE;
if (score == SCORE_OTHER)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org