You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Costin Manolache <co...@eng.sun.com> on 2000/08/11 23:51:10 UTC
PATCH: Jaxp support
Hi,
This is a new Liaison that use javax.xml to parse. It's not
complete - xerces is still needed to compile, but at runtime
it is possible to use only xalan.jar and a jaxp parser ( with support
for SAX2 ). You also need org.apache.xml.serialize in your classpath
( it is independent of xerces ).
Note that xalan + xerces will be faster - but without this fix
the idea of Liaison doesn't work ( since xerces is
hardcoded ).
There are few other changes that are needed to build
xalan without xerces.
( Crimson doesn't work right now - some fixes are required
in SAX2 impl. )
If you think it's usefull please check it in.
Costin
Index: src/org/apache/xalan/xslt/XSLTEngineImpl.java
===================================================================
RCS file:
/home/cvspublic/xml-xalan/src/org/apache/xalan/xslt/XSLTEngineImpl.java,v
retrieving revision 1.65
diff -u -r1.65 XSLTEngineImpl.java
--- src/org/apache/xalan/xslt/XSLTEngineImpl.java 2000/08/08 01:33:33
1.65
+++ src/org/apache/xalan/xslt/XSLTEngineImpl.java 2000/08/11 21:21:51
@@ -490,30 +490,40 @@
// 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.xerces.dom.NodeImpl)))
- {
- throw new
SAXException(XSLMessages.createMessage(XSLTErrorResources.ER_CANNOT_MIX_XERCESDOM,
null)); //"Can not mix non Xerces-DOM input with Xerces-DOM output!");
- }
+
+ // common condition
+ if(! "org.apache.xalan.xpath.dtm.DTMLiaison".equals(
m_parserLiaison.getClass().getName()))
+ return;
+
+ String specialNote="org.apache.xerces.dom.NodeImpl";
+
+ boolean specialResult=false;
+ if( resultNode != null && specialNote.equals(
resultNode.getClass().getName()))
+ specialResult=true;
+
+ boolean specialSource=false;
+ if( sourceNode != null && specialNote.equals(
sourceNode.getClass().getName()))
+ specialSource=true;
+ if( specialResult && ! specialSource && sourceNode!= null )
+ throw new
SAXException(XSLMessages.createMessage(XSLTErrorResources.
+ ER_CANNOT_MIX_XERCESDOM, null));
+ //"Can not mix non Xerces-DOM input with Xerces-DOM output!");
+
+ if( specialResult ) { // either sourceNote==null or specialSource
+ // XXX class.forName ?
XMLParserLiaison newLiaison = new
org.apache.xalan.xpath.xdom.XercesLiaison();
newLiaison.copyFromOtherLiaison((XMLParserLiaisonDefault)m_parserLiaison);
setExecContext(newLiaison);
+ return;
}
- 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(XSLMessages.createMessage(XSLTErrorResources.ER_CANNOT_MIX_XERCESDOM,
null)); //"Can not mix Xerces-DOM input with non Xerces-DOM output!");
- }
-
+
+ if( specialSource && ! specialResult && resultNode!=null )
+ throw new
SAXException(XSLMessages.createMessage(XSLTErrorResources.
+ ER_CANNOT_MIX_XERCESDOM, null));
+ //"Can not mix Xerces-DOM input with non Xerces-DOM output!");
+
+ if( specialSource ) { // either specialResult or resultNode==null
XMLParserLiaison newLiaison = new
org.apache.xalan.xpath.xdom.XercesLiaison();
newLiaison.copyFromOtherLiaison((XMLParserLiaisonDefault)m_parserLiaison);
setExecContext(newLiaison);