You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@locus.apache.org on 2000/09/08 00:21:11 UTC
cvs commit: xml-xalan/src/org/apache/xalan/xslt ExtensionNSHandler.java Process.java StylesheetRoot.java XSLTEngineImpl.java
mmidy 00/09/07 15:21:10
Modified: src/org/apache/xalan/xpath FuncGenerateId.java
MutableNodeListImpl.java XPathSupport.java
XPathSupportDefault.java
src/org/apache/xalan/xpath/dtm DTMLiaison.java
src/org/apache/xalan/xpath/xml JaxpLiaison.java
StringToStringTable.java XMLParserLiaison.java
XMLParserLiaisonDefault.java
src/org/apache/xalan/xslt ExtensionNSHandler.java
Process.java StylesheetRoot.java
XSLTEngineImpl.java
Log:
Check in changes for support of other parsers. Patches from Costin Manolache.
Revision Changes Path
1.7 +6 -5 xml-xalan/src/org/apache/xalan/xpath/FuncGenerateId.java
Index: FuncGenerateId.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/FuncGenerateId.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FuncGenerateId.java 2000/08/01 18:25:27 1.6
+++ FuncGenerateId.java 2000/09/07 22:21:01 1.7
@@ -95,14 +95,15 @@
// Xalan sometimes generates ids like N-1234, because the implementation uses
// hash code, which is not always non-negative. The fix is to use
// toHexString instead of toString.
- try
+
+ // Patch from Costin Manolache
+ if( execContext.supportsNodeNumber() )
{
- org.apache.xalan.xpath.dtm.DTMProxy dtmp = (org.apache.xalan.xpath.dtm.DTMProxy)context;
-
+ int nodeN=execContext.getNodeNumber(context);
return new XString((null == context)
- ? "" : "N"+Integer.toHexString(dtmp.getDTMNodeNumber()));
+ ? "" : "N"+Integer.toHexString(nodeN));
}
- catch(ClassCastException cce)
+ else
{
return new XString((null == context)
? "" : "N"+Integer.toHexString(context.hashCode()));
1.13 +26 -24 xml-xalan/src/org/apache/xalan/xpath/MutableNodeListImpl.java
Index: MutableNodeListImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/MutableNodeListImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MutableNodeListImpl.java 2000/08/17 18:31:37 1.12
+++ MutableNodeListImpl.java 2000/09/07 22:21:01 1.13
@@ -254,6 +254,8 @@
* Not yet ready for prime time.
* I can't use recursion in this.
*/
+ /* Patch from Costin Manolache
+ /* Commented out, does not seem to be used
private boolean addNodesInDocOrder(int start, int end, int testIndex,
NodeList nodelist, XPathSupport support)
{
@@ -326,7 +328,7 @@
}
return foundit;
}
-
+ */
/**
* Add the node into a vector of nodes where it should occur in
@@ -341,9 +343,9 @@
int insertIndex = -1;
if(test)
{
- try
+ if( support.supportsNodeNumber() )
{
- int index1 = ((org.apache.xalan.xpath.dtm.DTMProxy)node).getDTMNodeNumber();
+ int index1 = support.getNodeNumber(node);
// This needs to do a binary search, but a binary search
// is somewhat tough because the sequence test involves
@@ -359,7 +361,7 @@
{
continue;
}
- int index2 = ((org.apache.xalan.xpath.dtm.DTMProxy)node2).getDTMNodeNumber();
+ int index2 = support.getNodeNumber(node2);
if((index2 == index1))
{
i = -2; // Duplicate, suppress insert
@@ -375,9 +377,9 @@
insertIndex = i+1;
insertElementAt(node, insertIndex);
}
-
- }
- catch(ClassCastException cce)
+ }
+
+ else
{
// This needs to do a binary search, but a binary search
// is somewhat tough because the sequence test involves
@@ -394,15 +396,15 @@
}
// previous check already takes care of equal doc nodes
/*if ((child.getOwnerDocument() == node.getOwnerDocument() && null != child.getOwnerDocument())
- || child.getOwnerDocument()== node
- || node.getOwnerDocument() == child )
+ || child.getOwnerDocument()== node
+ || node.getOwnerDocument() == child )
{
- isNewDoc = false; */
- if(!isNodeAfter(node, child, support))
- {
- break;
- }
- /* }
+ isNewDoc = false; */
+ if(!isNodeAfter(node, child, support))
+ {
+ break;
+ }
+ /* }
// The assumption here is that the nodes in the original nodelist
// are already in document (access) order. After having made sure
// that it's not from documents already in the list, we then can just
@@ -412,14 +414,14 @@
// (if also from document 1+n) will be compared to nodes from document
// 1+n first, and will be inserted appropriately.
else
- isNewDoc = true;*/
+ isNewDoc = true;*/
}
if(i != -2)
{
- // if (isNewDoc)
- // insertIndex = size;
- // else
- insertIndex = i+1;
+ // if (isNewDoc)
+ // insertIndex = size;
+ // else
+ insertIndex = i+1;
insertElementAt(node, insertIndex);
}
}
@@ -468,13 +470,13 @@
{
// Assume first that the nodes are DTM nodes, since discovering node
// order is massivly faster for the DTM.
- try
+ if( support.supportsNodeNumber() )
{
- int index1 = ((org.apache.xalan.xpath.dtm.DTMProxy)node1).getDTMNodeNumber();
- int index2 = ((org.apache.xalan.xpath.dtm.DTMProxy)node2).getDTMNodeNumber();
+ int index1 = support.getNodeNumber(node1);
+ int index2 = support.getNodeNumber(node2);
return index1 <= index2;
}
- catch(ClassCastException cce)
+ else
{
// isNodeAfter will return true if node is after countedNode
// in document order. isDOMNodeAfter is sloooow (relativly).
1.13 +7 -0 xml-xalan/src/org/apache/xalan/xpath/XPathSupport.java
Index: XPathSupport.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/XPathSupport.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XPathSupport.java 2000/08/18 20:57:21 1.12
+++ XPathSupport.java 2000/09/07 22:21:01 1.13
@@ -357,4 +357,11 @@
public static final short XPATHPARSER = 3;
public static final short XPATHPROCESSOR = 4;
public static final short DATASOURCE = 5;
+
+ // Patch from Costin Manolache
+ // Support for extra functionality from the parser
+
+ public boolean supportsNodeNumber();
+
+ public int getNodeNumber( Node n );
}
1.21 +13 -0 xml-xalan/src/org/apache/xalan/xpath/XPathSupportDefault.java
Index: XPathSupportDefault.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/XPathSupportDefault.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XPathSupportDefault.java 2000/08/18 20:57:21 1.20
+++ XPathSupportDefault.java 2000/09/07 22:21:04 1.21
@@ -817,5 +817,18 @@
{
return new SimpleNodeLocator();
}
+
+ // Patch from Costin Manolache
+ // Support special functionality
+
+ public boolean supportsNodeNumber()
+ {
+ return false;
+ }
+
+ public int getNodeNumber( Node n )
+ {
+ return -1;
+ }
}
1.20 +11 -0 xml-xalan/src/org/apache/xalan/xpath/dtm/DTMLiaison.java
Index: DTMLiaison.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/dtm/DTMLiaison.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- DTMLiaison.java 2000/08/11 05:36:10 1.19
+++ DTMLiaison.java 2000/09/07 22:21:07 1.20
@@ -450,5 +450,16 @@
{
return DTMNodeLocator.getDefaultLocator();
}
+
+ //Patch from Costin Manolache
+ public boolean supportsNodeNumber()
+ {
+ return true;
+ }
+
+ public int getNodeNumber( Node node )
+ {
+ return ((DTMProxy)node).getDTMNodeNumber();
+ }
}
1.3 +1 -1 xml-xalan/src/org/apache/xalan/xpath/xml/JaxpLiaison.java
Index: JaxpLiaison.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/JaxpLiaison.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JaxpLiaison.java 2000/08/28 16:17:11 1.2
+++ JaxpLiaison.java 2000/09/07 22:21:08 1.3
@@ -118,7 +118,7 @@
// else
// sf=SAXParserFactory.newInstance(saxFactoryName);
- sf.setNamespaceAware( true );
+ //sf.setNamespaceAware( true );
SAXParser saxP=sf.newSAXParser();
Parser p=saxP.getParser();
1.6 +1 -1 xml-xalan/src/org/apache/xalan/xpath/xml/StringToStringTable.java
Index: StringToStringTable.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/StringToStringTable.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StringToStringTable.java 2000/03/06 20:13:45 1.5
+++ StringToStringTable.java 2000/09/07 22:21:08 1.6
@@ -61,7 +61,7 @@
* A very simple lookup table that stores a list of strings, the even
* number strings being keys, and the odd number strings being values.
*/
-public class StringToStringTable
+public class StringToStringTable implements java.io.Serializable
{
private int m_blocksize;
private String m_map[];
1.8 +12 -0 xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaison.java
Index: XMLParserLiaison.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaison.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XMLParserLiaison.java 2000/08/11 05:36:12 1.7
+++ XMLParserLiaison.java 2000/09/07 22:21:08 1.8
@@ -220,6 +220,18 @@
*/
public void copyFromOtherLiaison(XMLParserLiaisonDefault from)
throws SAXException;
+
+ // Patch from Costin Manolache
+ /**
+ * Set whether or not getNamespaceOfNode should use the Xerces/DOM2
+ * getNamespaceURI. This has to be set to true if the
+ * http://xml.org/sax/features/namespaces is set to false, or if
+ * the tree is mutated.
+ * Since it's used with casting it should be part of the liaison abstraction
+ */
+ public void setUseDOM2getNamespaceURI(boolean v);
+
+ public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler);
}
1.38 +6 -0 xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java
Index: XMLParserLiaisonDefault.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/XMLParserLiaisonDefault.java,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- XMLParserLiaisonDefault.java 2000/08/11 05:36:12 1.37
+++ XMLParserLiaisonDefault.java 2000/09/07 22:21:08 1.38
@@ -2062,6 +2062,12 @@
{
return m_errorHandler;
}
+
+ // Patch from Costin Manolache
+ public void setUseDOM2getNamespaceURI(boolean v)
+ {
+ // will be overriden in xerces liaison
+ }
}
1.10 +3 -2 xml-xalan/src/org/apache/xalan/xslt/ExtensionNSHandler.java
Index: ExtensionNSHandler.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/ExtensionNSHandler.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ExtensionNSHandler.java 2000/07/23 17:57:56 1.9
+++ ExtensionNSHandler.java 2000/09/07 22:21:10 1.10
@@ -352,11 +352,12 @@
xslp.m_stylesheetRoot.m_baseIdent);
// System.out.println("Extension URI: "+url.toString());
org.apache.xalan.xpath.xml.XMLParserLiaison liaison = xslp.m_parserLiaison;
- if(liaison instanceof org.apache.xalan.xpath.dtm.DTMLiaison)
+ // Patch from Costin Manolache
+ if("org.apache.xalan.xpath.dtm.DTMLiaison".equals( liaison.getClass().getName()))
{
// There ought to be a better way. At least if we know we
// have the DTM, we ought to have Xerces.
- liaison = new org.apache.xalan.xpath.xdom.XercesLiaison();
+ liaison = xslp.createXercesLiaison();
liaison.setErrorHandler(new ExtErrorHandler(url.toString()));
}
Element componentElement = null;
1.24 +2 -2 xml-xalan/src/org/apache/xalan/xslt/Process.java
Index: Process.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/Process.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Process.java 2000/08/08 02:10:00 1.23
+++ Process.java 2000/09/07 22:21:10 1.24
@@ -427,8 +427,8 @@
{
yesno = "yes";
}
-
- ((org.apache.xalan.xpath.xdom.XercesLiaison)xmlProcessorLiaison).setUseDOM2getNamespaceURI(yesno.equalsIgnoreCase("yes"));
+ // Patch from Costin Manolache
+ xmlProcessorLiaison.setUseDOM2getNamespaceURI(yesno.equalsIgnoreCase("yes"));
}
else if("-VALIDATE".equalsIgnoreCase(argv[i]))
{
1.37 +2 -1 xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java
Index: StylesheetRoot.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- StylesheetRoot.java 2000/07/19 14:35:36 1.36
+++ StylesheetRoot.java 2000/09/07 22:21:10 1.37
@@ -391,7 +391,8 @@
}
else if(null != outputTarget.getNode())
{
- if(processor.getXMLProcessorLiaison() instanceof org.apache.xalan.xpath.dtm.DTMLiaison)
+ // Patch from Costin Manolache
+ if( "org.apache.xalan.xpath.dtm.DTMLiaison".equals( processor.getXMLProcessorLiaison().getClass().getName()))
processor.error(XSLTErrorResources.ER_CANT_USE_DTM_FOR_OUTPUT); //"Can't use a DTMLiaison for an output DOM node... pass a org.apache.xalan.xpath.xdom.XercesLiaison instead!");
switch(outputTarget.getNode().getNodeType())
{
1.70 +66 -30 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.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- XSLTEngineImpl.java 2000/08/28 16:17:29 1.69
+++ XSLTEngineImpl.java 2000/09/07 22:21:10 1.70
@@ -225,6 +225,11 @@
* setStylesheetParam.
*/
Vector m_topLevelParams = new Vector();
+
+ /**
+ * The class name for the liaison. Defaults to Constants.LIAISON_CLASS
+ */
+ String parserLiaisonClassName = null;
/**
* The liason to the XML parser, so the XSL processor
@@ -354,19 +359,10 @@
protected XSLTEngineImpl()
throws org.xml.sax.SAXException
{
- try
- {
- String parserLiaisonClassName = Constants.LIAISON_CLASS;
- Class parserLiaisonClass = Class.forName(parserLiaisonClassName);
- Constructor parserLiaisonCtor = parserLiaisonClass.getConstructor(null);
- m_parserLiaison
- = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
- m_parserLiaison.setEnvSupport(this);
- }
- catch(Exception e)
- {
- throw new XSLProcessorException(e);
- }
+ // Patch from Costin Manolache
+ parserLiaisonClassName = Constants.LIAISON_CLASS;
+ m_parserLiaison = createLiaison();
+ m_parserLiaison.setEnvSupport(this);
}
/**
@@ -380,18 +376,10 @@
public XSLTEngineImpl(String parserLiaisonClassName)
throws org.xml.sax.SAXException
{
- try
- {
- Class parserLiaisonClass = Class.forName(parserLiaisonClassName);
- Constructor parserLiaisonCtor = parserLiaisonClass.getConstructor(null);
- m_parserLiaison
- = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
- m_parserLiaison.setEnvSupport(this);
- }
- catch(Exception e)
- {
- throw new XSLProcessorException(e);
- }
+ // Patch from Costin Manolache
+ this.parserLiaisonClassName = parserLiaisonClassName;
+ m_parserLiaison = createLiaison();
+ m_parserLiaison.setEnvSupport(this);
}
/**
@@ -452,6 +440,50 @@
m_parserLiaison.reset();
}
+ /**
+ * Get a Liaison class, as specified by parserLiaisonClassName property
+ * Patch from Costin Manolache
+ */
+ public XMLParserLiaison createLiaison()
+ throws org.xml.sax.SAXException
+ {
+ try
+ {
+ if( parserLiaisonClassName==null)
+ parserLiaisonClassName = Constants.LIAISON_CLASS;
+ Class parserLiaisonClass = Class.forName(parserLiaisonClassName);
+ Constructor parserLiaisonCtor = parserLiaisonClass.getConstructor(null);
+ XMLParserLiaison parserLiaison
+ = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
+ return parserLiaison;
+ }
+ catch(Exception e)
+ {
+ throw new XSLProcessorException(e);
+ }
+ }
+
+ /**
+ * Create a Xerces Liaison - used for special handling of DTM
+ * Patch from Costin Manolache
+ */
+ public XMLParserLiaison createXercesLiaison()
+ throws org.xml.sax.SAXException
+ {
+ try
+ {
+ Class parserLiaisonClass = Class.forName("org.apache.xalan.xpath.xdom.XercesLiaison");
+ Constructor parserLiaisonCtor = parserLiaisonClass.getConstructor(null);
+ XMLParserLiaison parserLiaison
+ = (XMLParserLiaison)parserLiaisonCtor.newInstance(null);
+ return parserLiaison;
+ }
+ catch(Exception e)
+ {
+ throw new XSLProcessorException(e);
+ }
+ }
+
/**
* <meta name="usage" content="internal"/>
* Get the object used to guard the stack from
@@ -514,7 +546,7 @@
if( specialResult )
{ // either sourceNote==null or specialSource
// XXX class.forName ?
- XMLParserLiaison newLiaison = new org.apache.xalan.xpath.xdom.XercesLiaison();
+ XMLParserLiaison newLiaison = createXercesLiaison();
newLiaison.copyFromOtherLiaison((XMLParserLiaisonDefault)m_parserLiaison);
@@ -528,7 +560,7 @@
if( specialSource )
{ // either specialResult or resultNode==null
- XMLParserLiaison newLiaison = new org.apache.xalan.xpath.xdom.XercesLiaison();
+ XMLParserLiaison newLiaison = createXercesLiaison();
newLiaison.copyFromOtherLiaison((XMLParserLiaisonDefault)m_parserLiaison);
@@ -840,8 +872,8 @@
if(null != inputSource.getNode())
{
sourceTree = inputSource.getNode();
- if((getXMLProcessorLiaison() instanceof org.apache.xalan.xpath.dtm.DTMLiaison) &&
- !(sourceTree instanceof org.apache.xalan.xpath.dtm.DTMProxy))
+ if(("org.apache.xalan.xpath.dtm.DTMLiaison".equals( getXMLProcessorLiaison().getClass().getName() )) &&
+ !( "org.apache.xalan.xpath.dtm.DTMProxy".equals(sourceTree.getClass().getName() )))
error(XSLTErrorResources.ER_CANT_USE_DTM_FOR_INPUT); //"Can't use a DTMLiaison for a input DOM node... pass a org.apache.xalan.xpath.xdom.XercesLiaison instead!");
}
@@ -3335,7 +3367,11 @@
// Force a XercesLiaison for right now, since we can't
// do the DTM with SAX right now.
- XMLParserLiaison liaison = new org.apache.xalan.xpath.xdom.XercesLiaison(errHandler);
+
+ // Patch from Costin Manolache
+ XMLParserLiaison liaison = createXercesLiaison();
+ liaison.setErrorHandler( errHandler );
+ // Was: new org.apache.xalan.xpath.xdom.XercesLiaison(errHandler);
liaison.copyFromOtherLiaison((XMLParserLiaisonDefault)m_parserLiaison);
setExecContext(liaison);