Update compatibility files so that they run with new DTM changes
diff --git a/compat_src/org/apache/xalan/xpath/XBoolean.java b/compat_src/org/apache/xalan/xpath/XBoolean.java
index a1395bb..cc75449 100644
--- a/compat_src/org/apache/xalan/xpath/XBoolean.java
+++ b/compat_src/org/apache/xalan/xpath/XBoolean.java
@@ -130,7 +130,7 @@
* Tell if two objects are functionally equal.
*/
public boolean equals(XObject obj2)
- throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ throws org.xml.sax.SAXException
{
return m_xboolean.equals(obj2);
}
diff --git a/compat_src/org/apache/xalan/xpath/XBooleanStatic.java b/compat_src/org/apache/xalan/xpath/XBooleanStatic.java
index 9639687..d9a6ca1 100644
--- a/compat_src/org/apache/xalan/xpath/XBooleanStatic.java
+++ b/compat_src/org/apache/xalan/xpath/XBooleanStatic.java
@@ -80,7 +80,7 @@
* Tell if two objects are functionally equal.
*/
public boolean equals(XObject obj2)
- throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ throws org.xml.sax.SAXException
{
return m_xboolean.equals(obj2);
}
diff --git a/compat_src/org/apache/xalan/xpath/XNodeSet.java b/compat_src/org/apache/xalan/xpath/XNodeSet.java
index 019ffee..9baa445 100644
--- a/compat_src/org/apache/xalan/xpath/XNodeSet.java
+++ b/compat_src/org/apache/xalan/xpath/XNodeSet.java
@@ -57,12 +57,18 @@
package org.apache.xalan.xpath;
import org.w3c.dom.*;
+import org.w3c.dom.Text;
import org.w3c.dom.traversal.NodeIterator;
import org.w3c.dom.traversal.NodeFilter;
import java.text.*;
import org.apache.xpath.XPathContext;
import org.apache.xpath.NodeSet;
+import org.apache.xpath.DOMHelper;
+import org.apache.xml.dtm.ref.DTMNodeIterator;
+import org.apache.xml.dtm.ref.DTMNodeList;
+import org.apache.xml.dtm.ref.DTMManagerDefault;
+import org.apache.xml.dtm.DTM;
/**
* <meta name="usage" content="general"/>
@@ -72,6 +78,7 @@
public class XNodeSet extends XObject
{
org.apache.xpath.objects.XNodeSet m_xnodeset;
+ DTMManagerDefault dtmMgr = new DTMManagerDefault();
/**
* Construct a XNodeSet object.
@@ -79,7 +86,8 @@
public XNodeSet(NodeList val)
{
super();
- m_xnodeset = new org.apache.xpath.objects.XNodeSet(new NodeIteratorWrapper(val)) ;
+ int node = dtmMgr.getDTMHandleFromNode(val.item(0));
+ m_xnodeset = new org.apache.xpath.objects.XNodeSet(dtmMgr.createDTMIterator(node)) ;
}
/**
@@ -88,7 +96,7 @@
public XNodeSet()
{
super();
- m_xnodeset = new org.apache.xpath.objects.XNodeSet();
+ m_xnodeset = new org.apache.xpath.objects.XNodeSet(dtmMgr);
}
/**
@@ -96,8 +104,8 @@
*/
public XNodeSet(Node n)
{
- super(n);
- m_xnodeset = new org.apache.xpath.objects.XNodeSet(n);
+ super(n);
+ m_xnodeset = new org.apache.xpath.objects.XNodeSet(dtmMgr.getDTMHandleFromNode(n), dtmMgr);
}
@@ -123,7 +131,7 @@
*/
double getNumberFromNode(Node n)
{
- return m_xnodeset.getNumberFromNode(n);
+ return m_xnodeset.getNumberFromNode(dtmMgr.getDTMHandleFromNode(n));
}
/**
@@ -148,8 +156,23 @@
*/
static String getStringFromNode(Node n)
{
- return org.apache.xpath.objects.XNodeSet.getStringFromNode(n);
+ switch (n.getNodeType())
+ {
+ case Node.ELEMENT_NODE :
+ case Node.DOCUMENT_NODE :
+ return DOMHelper.getNodeData(n);
+ case Node.CDATA_SECTION_NODE :
+ case Node.TEXT_NODE :
+ return ((Text) n).getData();
+ case Node.COMMENT_NODE :
+ case Node.PROCESSING_INSTRUCTION_NODE :
+ case Node.ATTRIBUTE_NODE :
+ return n.getNodeValue();
+ default :
+ return DOMHelper.getNodeData(n);
+ }
}
+
/**
* Cast result object to a string.
@@ -164,7 +187,7 @@
*/
public DocumentFragment rtree(XPathSupport support)
{
- return m_xnodeset.rtree((XPathContext) support);
+ return rtree((XPathContext) support);
}
/**
@@ -176,23 +199,25 @@
*/
public DocumentFragment rtree(XPathContext support)
{
- return m_xnodeset.rtree(support);
+ org.apache.xpath.XPathContext context = (org.apache.xpath.XPathContext)support;
+ int result = m_xnodeset.rtree(context);
+ return (DocumentFragment)context.getDTMManager().getDTM(result).getNode(result);
}
/**
* Cast result object to a nodelist.
*/
- public NodeIterator nodeset()
+ public NodeList nodeset()
{
- return m_xnodeset.nodeset();
+ return new DTMNodeList(m_xnodeset.nodeset());
}
/**
* Cast result object to a nodelist.
*/
- public NodeSet mutableNodeset()
+ public NodeList mutableNodeset()
{
- return m_xnodeset.mutableNodeset();
+ return new DTMNodeList(m_xnodeset.mutableNodeset());
}
/**
@@ -201,7 +226,7 @@
public boolean lessThan(XObject obj2)
throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
{
- return m_xnodeset.lessThan(obj2);
+ return m_xnodeset.lessThan(obj2.m_xObject);
}
/**
@@ -210,7 +235,7 @@
public boolean lessThanOrEqual(XObject obj2)
throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
{
- return m_xnodeset.lessThanOrEqual(obj2);
+ return m_xnodeset.lessThanOrEqual(obj2.m_xObject);
}
/**
@@ -219,7 +244,7 @@
public boolean greaterThan(XObject obj2)
throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
{
- return m_xnodeset.greaterThan(obj2);
+ return m_xnodeset.greaterThan(obj2.m_xObject);
}
/**
@@ -228,14 +253,14 @@
public boolean greaterThanOrEqual(XObject obj2)
throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
{
- return m_xnodeset.greaterThanOrEqual(obj2);
+ return m_xnodeset.greaterThanOrEqual(obj2.m_xObject);
}
/**
* Tell if two objects are functionally equal.
*/
public boolean equals(XObject obj2)
- throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ throws org.xml.sax.SAXException
{
return m_xnodeset.equals(obj2);
}
@@ -246,10 +271,10 @@
public boolean notEquals(XObject obj2)
throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
{
- return m_xnodeset.notEquals(obj2);
+ return m_xnodeset.notEquals(obj2.m_xObject);
}
- static class NodeIteratorWrapper implements NodeIterator
+ static class NodeIteratorWrapper extends org.apache.xpath.NodeSet
{
/** Position of next node */
@@ -257,6 +282,7 @@
/** Document fragment instance this will wrap */
private NodeList m_list;
+ private org.apache.xml.dtm.DTMManager dtmManager;
/**
* Constructor NodeIteratorWrapper
@@ -266,60 +292,12 @@
*/
NodeIteratorWrapper(NodeList list)
{
+ super();
m_list = list;
+ dtmManager = new org.apache.xml.dtm.ref.DTMManagerDefault();
}
- /**
- * The root node of the Iterator, as specified when it was created.
- *
- * @return null
- */
- public Node getRoot()
- {
- return null;
- }
-
- /**
- * This attribute determines which node types are presented via the
- * iterator. The available set of constants is defined in the
- * <code>NodeFilter</code> interface.
- *
- * @return All node types
- */
- public int getWhatToShow()
- {
- return NodeFilter.SHOW_ALL;
- }
-
- /**
- * The filter used to screen nodes.
- *
- * @return null
- */
- public NodeFilter getFilter()
- {
- return null;
- }
-
- /**
- * The value of this flag determines whether the children of entity
- * reference nodes are visible to the iterator. If false, they will be
- * skipped over.
- * <br> To produce a view of the document that has entity references
- * expanded and does not expose the entity reference node itself, use the
- * whatToShow flags to hide the entity reference node and set
- * expandEntityReferences to true when creating the iterator. To produce
- * a view of the document that has entity reference nodes but no entity
- * expansion, use the whatToShow flags to show the entity reference node
- * and set expandEntityReferences to false.
- *
- * @return true
- */
- public boolean getExpandEntityReferences()
- {
- return true;
- }
-
+
/**
* Returns the next node in the set and advances the position of the
* iterator in the set. After a NodeIterator is created, the first call
@@ -330,15 +308,18 @@
* INVALID_STATE_ERR: Raised if this method is called after the
* <code>detach</code> method was invoked.
*/
- public Node nextNode() throws DOMException
+ public int nextNode() throws DOMException
{
+ Node n;
if (m_pos < m_list.getLength())
{
- return m_list.item(m_pos++);
+ n = m_list.item(m_pos++);
+ return dtmManager.getDTMHandleFromNode(n);
}
+
else
- return null;
+ return DTM.NULL;
}
/**
@@ -350,15 +331,17 @@
* INVALID_STATE_ERR: Raised if this method is called after the
* <code>detach</code> method was invoked.
*/
- public Node previousNode() throws DOMException
+ public int previousNode() throws DOMException
{
+ Node n;
if (m_pos >0)
{
- return m_list.item(m_pos-1);
+ n = m_list.item(m_pos-1);
+ return dtmManager.getDTMHandleFromNode(n);
}
else
- return null;
+ return DTM.NULL;
}
/**
diff --git a/compat_src/org/apache/xalan/xpath/XNull.java b/compat_src/org/apache/xalan/xpath/XNull.java
index 473a658..0da503b 100644
--- a/compat_src/org/apache/xalan/xpath/XNull.java
+++ b/compat_src/org/apache/xalan/xpath/XNull.java
@@ -124,7 +124,7 @@
*/
public DocumentFragment rtree(XPathSupport support)
{
- return m_xnull.rtree((XPathContext)support);
+ return rtree((XPathContext)support);
}
/**
@@ -136,14 +136,15 @@
*/
public DocumentFragment rtree(XPathContext support)
{
- return m_xnull.rtree(support);
- }
-
+ org.apache.xpath.XPathContext context = (org.apache.xpath.XPathContext)support;
+ int result = m_xnull.rtree(context);
+ return (DocumentFragment)context.getDTMManager().getDTM(result).getNode(result);
+ }
/**
* Cast result object to a nodelist.
*/
- public NodeIterator nodeset()
+ public NodeList nodeset()
{
return null;
}
diff --git a/compat_src/org/apache/xalan/xpath/XNumber.java b/compat_src/org/apache/xalan/xpath/XNumber.java
index bf8e286..1ca862f 100644
--- a/compat_src/org/apache/xalan/xpath/XNumber.java
+++ b/compat_src/org/apache/xalan/xpath/XNumber.java
@@ -131,7 +131,7 @@
* Tell if two objects are functionally equal.
*/
public boolean equals(XObject obj2)
- throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ throws org.xml.sax.SAXException
{
return m_xnumber.equals(obj2);
}
diff --git a/compat_src/org/apache/xalan/xpath/XObject.java b/compat_src/org/apache/xalan/xpath/XObject.java
index f0cb33e..9302a3a 100644
--- a/compat_src/org/apache/xalan/xpath/XObject.java
+++ b/compat_src/org/apache/xalan/xpath/XObject.java
@@ -56,6 +56,11 @@
*/
package org.apache.xalan.xpath;
+import org.w3c.dom.*;
+import java.io.Serializable;
+import org.apache.xpath.res.XPATHErrorResources;
+import org.apache.xalan.res.XSLMessages;
+
/**
* <meta name="usage" content="general"/>
@@ -64,16 +69,16 @@
* This class acts as the base class to other XPath type objects,
* such as XString, and provides polymorphic casting capabilities.
*/
-public class XObject extends org.apache.xpath.objects.XObject
+public class XObject extends Object implements Serializable
{
-
+ org.apache.xpath.objects.XObject m_xObject;
/**
* Create an XObject.
*/
public XObject()
{
- super();
+ m_xObject = new org.apache.xpath.objects.XObject() ;
}
/**
@@ -81,7 +86,188 @@
*/
public XObject(Object obj)
{
- super(obj);
- }
+ m_xObject = new org.apache.xpath.objects.XObject(obj) ;
+ }
+
+ /**
+ * Tell what kind of class this is.
+ */
+ public int getType()
+ {
+ return m_xObject.getType();
+ }
+
+ /**
+ * Given a request type, return the equivalent string.
+ * For diagnostic purposes.
+ */
+ protected String getTypeString() // PR:DMAN4MBJ4D Submitted by:<garyp@firstech.com> change to protected
+ {
+ return "#UNKNOWN";
+ }
+
+ /**
+ * Cast result object to a number.
+ */
+ public double num()
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return m_xObject.num();
+ }
+
+ /**
+ * Cast result object to a boolean.
+ */
+ public boolean bool()
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return m_xObject.bool();
+ }
+
+ /**
+ * Cast result object to a string.
+ */
+ public String str()
+ {
+ return m_xObject.str();
+ }
+
+ public String toString()
+ {
+ return m_xObject.toString();
+ }
+
+ /**
+ * Cast result object to a result tree fragment.
+ */
+ public DocumentFragment rtree(XPathSupport support)
+ {
+ org.apache.xpath.XPathContext context = (org.apache.xpath.XPathContext)support;
+ int result = m_xObject.rtree(context);
+ return (DocumentFragment)context.getDTMManager().getDTM(result).getNode(result);
+ }
+
+ /**
+ * For functions to override.
+ */
+ public DocumentFragment rtree()
+ {
+ return null;
+ }
+
+ /**
+ * Return a java object that's closes to the represenation
+ * that should be handed to an extension.
+ */
+ public Object object()
+ {
+ return m_xObject.object();
+ }
+
+ /**
+ * Cast result object to a nodelist.
+ */
+ public NodeList nodeset()
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ error(XPATHErrorResources.ER_CANT_CONVERT_TO_NODELIST, new Object[] {getTypeString()}); //"Can not convert "+getTypeString()+" to a NodeList!");
+ return null;
+ }
+
+ /**
+ * Cast result object to a nodelist.
+ */
+ public NodeList mutableNodeset()
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return new org.apache.xml.dtm.ref.DTMNodeList(m_xObject.mutableNodeset());
+ }
+
+ /**
+ * Cast object to type t.
+ */
+ public Object castToType(int t, XPathSupport support)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return m_xObject.castToType(t, (org.apache.xpath.XPathContext) support);
+ }
+
+ /**
+ * Tell if one object is less than the other.
+ */
+ public boolean lessThan(XObject obj2)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+
+ return m_xObject.lessThan(obj2.m_xObject);
+ }
+
+ /**
+ * Tell if one object is less than or equal to the other.
+ */
+ public boolean lessThanOrEqual(XObject obj2)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return m_xObject.lessThanOrEqual(obj2.m_xObject);
+ }
+
+ /**
+ * Tell if one object is less than the other.
+ */
+ public boolean greaterThan(XObject obj2)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return m_xObject.greaterThan(obj2.m_xObject);
+ }
+
+ /**
+ * Tell if one object is less than the other.
+ */
+ public boolean greaterThanOrEqual(XObject obj2)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return m_xObject.greaterThanOrEqual(obj2.m_xObject);
+ }
+
+ /**
+ * Tell if two objects are functionally equal.
+ */
+ public boolean equals(XObject obj2)
+ throws org.xml.sax.SAXException
+ {
+ return m_xObject.equals(obj2.m_xObject);
+ }
+
+ /**
+ * Tell if two objects are functionally not equal.
+ */
+ public boolean notEquals(XObject obj2)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ return m_xObject.notEquals(obj2.m_xObject);
+ }
+
+ /**
+ * Tell the user of an error, and probably throw an
+ * exception.
+ */
+ protected void error(int msg)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ error (msg, null);
+ }
+
+ /**
+ * Tell the user of an error, and probably throw an
+ * exception.
+ */
+ protected void error(int msg, Object[] args)
+ throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ {
+ String fmsg = XSLMessages.createXPATHMessage(msg, args);
+
+
+ throw new org.xml.sax.SAXException(fmsg);
+ }
}
diff --git a/compat_src/org/apache/xalan/xpath/XPathSupport.java b/compat_src/org/apache/xalan/xpath/XPathSupport.java
index 0a98708..7cce017 100644
--- a/compat_src/org/apache/xalan/xpath/XPathSupport.java
+++ b/compat_src/org/apache/xalan/xpath/XPathSupport.java
@@ -73,7 +73,7 @@
* of this should derive from XPathSupportDefault (hence, it should
* probably be an abstract class instead of an interface).
*/
-public interface XPathSupport extends org.apache.xalan.extensions.ExpressionContext
+public interface XPathSupport
{
}
diff --git a/compat_src/org/apache/xalan/xpath/XRTreeFrag.java b/compat_src/org/apache/xalan/xpath/XRTreeFrag.java
index a08cf18..cabeffe 100644
--- a/compat_src/org/apache/xalan/xpath/XRTreeFrag.java
+++ b/compat_src/org/apache/xalan/xpath/XRTreeFrag.java
@@ -67,14 +67,16 @@
{
org.apache.xpath.objects.XRTreeFrag m_xrtreefrag;
+ org.apache.xpath.XPathContext context = new org.apache.xpath.XPathContext();
+
/**
* Create an XObject.
*/
public XRTreeFrag(DocumentFragment frag)
{
- super(frag);
- m_xrtreefrag = new org.apache.xpath.objects.XRTreeFrag(frag);
+ super(frag);
+ m_xrtreefrag = new org.apache.xpath.objects.XRTreeFrag(context.getDTMHandleFromNode(frag), context);
}
/**
@@ -97,7 +99,7 @@
/**
* Cast result object to a number.
*/
- public double num()
+ public double num() throws javax.xml.transform.TransformerException
{
return m_xrtreefrag.num();
}
@@ -123,22 +125,23 @@
*/
public DocumentFragment rtree()
{
- return m_xrtreefrag.rtree();
- }
+ int result = m_xrtreefrag.rtree(context);
+ return (DocumentFragment)context.getDTMManager().getDTM(result).getNode(result);
+ }
/**
* Cast result object to a nodelist. (special function).
*/
public NodeList convertToNodeset()
{
- return m_xrtreefrag.convertToNodeset();
+ return ((DocumentFragment)this.object()).getChildNodes();
}
/**
* Tell if two objects are functionally equal.
*/
public boolean equals(XObject obj2)
- throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ throws org.xml.sax.SAXException
{
return m_xrtreefrag.equals(obj2);
}
diff --git a/compat_src/org/apache/xalan/xpath/XString.java b/compat_src/org/apache/xalan/xpath/XString.java
index 9d2dc6e..67d00b0 100644
--- a/compat_src/org/apache/xalan/xpath/XString.java
+++ b/compat_src/org/apache/xalan/xpath/XString.java
@@ -101,7 +101,52 @@
*/
public static double castToNum(String s)
{
- return org.apache.xpath.objects.XString.castToNum(s);
+ double result;
+
+ if (null == s)
+ result = 0.0;
+ else
+ {
+ try
+ {
+
+ /**
+ * TODO: Adjust this for locale. Need to take into
+ * account the lang parameter on the xsl:sort
+ */
+
+ // It seems we can not use this as it just parses the
+ // start of the string until it finds a non-number char,
+ // which is not what we want according to the XSLT spec.
+ // Also, I *think* this is a local-specific
+ // parse, which is also not what we want according to the
+ // XSLT spec (see below).
+ // NumberFormat formatter = NumberFormat.getNumberInstance();
+ // result = formatter.parse(s.trim()).doubleValue();
+ // The dumb XSLT spec says: "The number function should
+ // not be used for conversion of numeric data occurring
+ // in an element in an XML document unless the element
+ // is of a type that represents numeric data in a
+ // language-neutral format (which would typically be
+ // transformed into a language-specific format for
+ // presentation to a user). In addition, the number
+ // function cannot be used unless the language-neutral
+ // format used by the element is consistent with the
+ // XPath syntax for a Number."
+ // So I guess we need to check, if the default local
+ // is french, does Double.valueOf use the local specific
+ // parse? Or does it use the ieee parse?
+ result = Double.valueOf(s.trim()).doubleValue();
+ }
+
+ // catch (ParseException e)
+ catch (NumberFormatException nfe)
+ {
+ result = Double.NaN;
+ }
+ }
+
+ return result;
}
/**
@@ -132,8 +177,10 @@
* Cast result object to a result tree fragment.
*/
public DocumentFragment rtree(XPathSupport support)
- {
- return m_xstring.rtree((XPathContext)support);
+ {
+ org.apache.xpath.XPathContext context = (org.apache.xpath.XPathContext)support;
+ int result = m_xstring.rtree(context);
+ return (DocumentFragment)context.getDTMManager().getDTM(result).getNode(result);
}
@@ -145,15 +192,18 @@
* @return A document fragment with this string as a child node
*/
public DocumentFragment rtree(XPathContext support)
- {
- return m_xstring.rtree(support);
- }
+ {
+ org.apache.xpath.XPathContext context = (org.apache.xpath.XPathContext)support;
+ int result = m_xstring.rtree(context);
+ return (DocumentFragment)context.getDTMManager().getDTM(result).getNode(result);
+ }
+
/**
* Tell if two objects are functionally equal.
*/
public boolean equals(XObject obj2)
- throws org.xml.sax.SAXException, javax.xml.transform.TransformerException
+ throws org.xml.sax.SAXException
{
return m_xstring.equals(obj2);
}
diff --git a/compat_src/org/apache/xalan/xpath/xdom/XercesLiaison.java b/compat_src/org/apache/xalan/xpath/xdom/XercesLiaison.java
index 5622796..c450870 100644
--- a/compat_src/org/apache/xalan/xpath/xdom/XercesLiaison.java
+++ b/compat_src/org/apache/xalan/xpath/xdom/XercesLiaison.java
@@ -287,7 +287,7 @@
* output document. Implementation of XMLParserLiaison
* interface method.
*/
- public Document createDocument()
+ static public Document createDocument()
{
org.apache.xerces.dom.DocumentImpl doc = new org.apache.xerces.dom.DocumentImpl();
return doc;
diff --git a/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java b/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
index a3a239f..9b00993 100644
--- a/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
+++ b/compat_src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
@@ -63,7 +63,6 @@
import org.xml.sax.*;
import org.w3c.dom.*;
-import org.apache.xalan.xpath.xml.*;
import org.apache.xalan.xpath.*;
import org.apache.xpath.*;
import org.apache.xalan.xpath.xml.XMLParserLiaison;
diff --git a/compat_src/org/apache/xalan/xslt/StylesheetRoot.java b/compat_src/org/apache/xalan/xslt/StylesheetRoot.java
index 892c31a..4395da7 100644
--- a/compat_src/org/apache/xalan/xslt/StylesheetRoot.java
+++ b/compat_src/org/apache/xalan/xslt/StylesheetRoot.java
@@ -217,7 +217,11 @@
}*/
// Find the root pattern in the XSL.
- ElemTemplate rootRule = m_sRootObject.getTemplateComposed(processor.getTransformer().getXPathContext(), sourceTree, null, -1, false);
+ int child = processor.getTransformer().getXPathContext().getDTMHandleFromNode(sourceTree);
+ ElemTemplate rootRule = m_sRootObject.getTemplateComposed(processor.getTransformer().getXPathContext(),
+ child,
+ null, -1, false,
+ processor.getTransformer().getXPathContext().getDTM(child));
//this.findTemplate(processor, sourceTree, sourceTree);
if(null == rootRule)
@@ -326,7 +330,7 @@
// Output the action of the found root rule. All processing
// occurs from here. buildResultFromTemplate is highly recursive.
- rootRule.execute(processor.getTransformer(), sourceTree, null);
+ rootRule.execute(processor.getTransformer());
processor.getTransformer().getResultTreeHandler().endDocument();
@@ -338,10 +342,11 @@
processor.displayDuration("transform", sourceTree);
}
}
- catch(TransformerException te)
+ catch (TransformerException te)
{
- throw new SAXException(te);
- }
+ throw new SAXException(te);
+ }
+
finally
{
if (null != ostream)
diff --git a/compat_src/org/apache/xalan/xslt/XSLProcessorContext.java b/compat_src/org/apache/xalan/xslt/XSLProcessorContext.java
index c6a2294..a4d543f 100644
--- a/compat_src/org/apache/xalan/xslt/XSLProcessorContext.java
+++ b/compat_src/org/apache/xalan/xslt/XSLProcessorContext.java
@@ -78,8 +78,7 @@
{
super((TransformerImpl)(processor.getTransformer()),
- stylesheetTree,
- sourceTree, sourceNode, mode);
+ stylesheetTree);
}
diff --git a/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java b/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java
index 7f00511..8bfea3e 100644
--- a/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java
+++ b/compat_src/org/apache/xalan/xslt/XSLTEngineImpl.java
@@ -112,7 +112,7 @@
import org.apache.xml.utils.TreeWalker;
import org.apache.xml.utils.QName;
import org.apache.xml.utils.DefaultErrorHandler;
-import org.apache.xalan.stree.SourceTreeHandler;
+import org.apache.xalan.transformer.TransformerHandlerImpl;
/**
@@ -471,8 +471,8 @@
m_transformerImpl = (TransformerImpl)templates.newTransformer();
if (m_problemListener != null)
m_transformerImpl.setErrorListener(m_problemListener);
- if (m_liaison != null)
- m_transformerImpl.getXPathContext().setDOMHelper(m_liaison);
+ // if (m_liaison != null)
+ // m_transformerImpl.getXPathContext().setDOMHelper(m_liaison);
}
catch (TransformerConfigurationException tce)
@@ -786,14 +786,19 @@
//StylesheetHandler inputHandler = (StylesheetHandler)m_processor.getTemplatesBuilder();
//reader.setContentHandler( inputHandler );
- SourceTreeHandler handler = new SourceTreeHandler();
+ /*TransformerHandlerImpl handler = new TransformerHandlerImpl(getTransformer(), false,
+ xmlIdentifier);
reader.setContentHandler(handler);
reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
-
+ */
// Kick off the parse. When the ContentHandler gets
// the startDocument event, it will call transformNode( node ).
- reader.parse( SAXSource.sourceToInputSource(iSource));
+ /* reader.parse( SAXSource.sourceToInputSource(iSource));
sourceTree = handler.getRoot();
+ */
+ org.apache.xml.dtm.DTMManager dtmManager = new org.apache.xml.dtm.ref.DTMManagerDefault();
+ org.apache.xml.dtm.DTM dtm = dtmManager.getDTM(inputSource.getSourceObject(), true, null, false, false);
+ sourceTree = dtm.getNode(dtm.getDocument());
}
}
catch(Exception e)
@@ -857,7 +862,7 @@
parser.initXPath(compiler, "id("+fragID+")", nsNode);
org.apache.xpath.objects.XObject xobj = xpath.execute(xpathContext, fragBase, nsNode);
- nl = xobj.nodeset();
+ nl = new org.apache.xml.dtm.ref.DTMNodeIterator(xobj.nodeset());
if(nl.nextNode() == null)
{
// xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@id='"+fragID+"']", fragBase, nsNode);
@@ -868,7 +873,7 @@
parser.initXPath(compiler, "//*[@id='"+fragID+"']", nsNode);
xobj = xpath.execute(xpathContext, fragBase, nsNode);
- nl = xobj.nodeset();
+ nl = new org.apache.xml.dtm.ref.DTMNodeIterator(xobj.nodeset());
if(nl.nextNode() == null)
{
// xobj = Stylesheet.evalXPathStr(getExecContext(), "//*[@name='"+fragID+"']", fragBase, nsNode);
@@ -878,7 +883,7 @@
// Parse the xpath
parser.initXPath(compiler, "//*[@name='"+fragID+"']", nsNode);
xobj = xpath.execute(xpathContext, fragBase, nsNode);
- nl = xobj.nodeset();
+ nl = new org.apache.xml.dtm.ref.DTMNodeIterator(xobj.nodeset());
if(nl.nextNode() == null)
{
// Well, hell, maybe it's an XPath...
@@ -890,7 +895,7 @@
// Parse the xpath
parser.initXPath(compiler, fragID, nsNode);
xobj = xpath.execute(xpathContext, fragBase, nsNode);
- nl = xobj.nodeset();
+ nl = new org.apache.xml.dtm.ref.DTMNodeIterator(xobj.nodeset());
}
}
}
@@ -2104,7 +2109,7 @@
*/
public void setOutputStream(java.io.OutputStream os)
{
- SourceTreeHandler handler = new SourceTreeHandler(m_transformerImpl);
+ TransformerHandlerImpl handler = new TransformerHandlerImpl(m_transformerImpl, false, null);
handler.setResult(new StreamResult(os));
}
@@ -2259,7 +2264,7 @@
*/
public void setStylesheetParam(String key, XObject value)
{
- setParameter(key, value);
+ setParameter(key, value.object());
}
/**