robweir 00/03/14 13:57:16
Modified: src/org/apache/xalan/xslt Tag: Bxalan_1_0_0
XSLTEngineImpl.java
Log:
Fix smart switch between XercesDOM and DTM
Revision Changes Path
No revision
No revision
1.55.2.1 +23 -2 xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java
Index: XSLTEngineImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
retrieving revision 1.55
retrieving revision 1.55.2.1
diff -u -r1.55 -r1.55.2.1
--- XSLTEngineImpl.java 2000/03/02 20:52:02 1.55
+++ XSLTEngineImpl.java 2000/03/14 21:57:16 1.55.2.1
@@ -473,18 +473,33 @@
/**
* Switch the liaisons if needed according to the type of
* the source and result nodes.
+ * @param sourceNode The node being transformed -- may be null.
+ * @param resultNode The node to which result nodes will be added -- may
be null.
*/
void switchLiaisonsIfNeeded(Node sourceNode, Node resultNode)
throws SAXException
{
// If the result node is a xerces node, try to be smart about which
// liaison is going to be used.
+
+ // Here's the logic:
+
+ // Source - Result - What we do
+ // ==========================================
+ // DTM - Xerces DOM - error, you can't mix types
+ // DTM - DTM - Do nothing, We're OK
+ // Xerces DOM - DTM - error, you can't have DTM as a result
+ // Xerces DOM - Xerces DOM - switch to Xerces Liaison
+
+
if((null != resultNode) && (resultNode instanceof
org.apache.xerces.dom.NodeImpl) &&
(m_parserLiaison instanceof org.apache.xalan.xpath.dtm.DTMLiaison))
{
if((null != sourceNode)
- && (!(sourceNode instanceof
org.apache.xalan.xpath.xdom.XercesLiaison)))
- throw new SAXException("Can not mix DTM input with DOM output!");
+ && (!(sourceNode instanceof org.apache.xerces.dom.NodeImpl)))
+ {
+ throw new SAXException("Can not mix non Xerces-DOM input with
Xerces-DOM output!");
+ }
XMLParserLiaison newLiaison = new
org.apache.xalan.xpath.xdom.XercesLiaison();
newLiaison.copyFromOtherLiaison((XMLParserLiaisonDefault)m_parserLiaison);
@@ -493,6 +508,12 @@
else if((null != sourceNode)&& (sourceNode instanceof
org.apache.xerces.dom.NodeImpl) &&
(m_parserLiaison instanceof org.apache.xalan.xpath.dtm.DTMLiaison))
{
+ if((null != resultNode)
+ && (!(resultNode instanceof org.apache.xerces.dom.NodeImpl)))
+ {
+ throw new SAXException("Can not mix Xerces-DOM input with non
Xerces-DOM output!");
+ }
+
XMLParserLiaison newLiaison = new
org.apache.xalan.xpath.xdom.XercesLiaison();
newLiaison.copyFromOtherLiaison((XMLParserLiaisonDefault)m_parserLiaison);
setExecContext(newLiaison);