You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mk...@apache.org on 2003/03/18 17:24:33 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax DOM2SAX.java TransformerImpl.java
mkwan 2003/03/18 08:24:33
Modified: java/src/org/apache/xalan/xsltc/dom Tag: XSLTC_DTM
DOMAdapter.java DOMWSFilter.java KeyIndex.java
LoadDocument.java SAXImpl.java XSLTCDTMManager.java
java/src/org/apache/xalan/xsltc/runtime Tag: XSLTC_DTM
AbstractTranslet.java BasisLibrary.java
java/src/org/apache/xalan/xsltc/trax Tag: XSLTC_DTM
DOM2SAX.java TransformerImpl.java
Log:
XSLTC_DTM performance work
New solution for DOM input. Use SAXImpl + DOM2SAX to handle DOM
input. This is the solution used in the old XSLTC. The DOMImpl
class is completely deprecated. This solution is better
than DOMImpl on top of DOM2DTM for the following reasons:
1. DOM2DTM is known to be slow.
2. DOM2DTM is an incremental model while DOMImpl is not.
3. There are too much code duplication between DOMImpl and SAXImpl
Under the new solution, any improvement to SAXImpl and SAX2DTM2 will
also benefit the DOM case. There is no need to have separate optimizations
for the DOM case.
This solution is a little sophisticated than the old XSLTC solution in
that we borrow some code from DOM2DTM (e.g. handling for id function
and unparsed entity). The end result is that conformance in trax.dom
is better than the old XSLTC.
Revision Changes Path
No revision
No revision
1.11.10.19 +12 -32 xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
Index: DOMAdapter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
retrieving revision 1.11.10.18
retrieving revision 1.11.10.19
diff -u -r1.11.10.18 -r1.11.10.19
--- DOMAdapter.java 12 Mar 2003 17:44:11 -0000 1.11.10.18
+++ DOMAdapter.java 18 Mar 2003 16:24:32 -0000 1.11.10.19
@@ -70,7 +70,6 @@
import org.apache.xalan.xsltc.runtime.Hashtable;
import org.apache.xml.dtm.DTM;
import org.apache.xml.dtm.DTMAxisIterator;
-import org.apache.xml.dtm.ref.DTMDefaultBase;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -78,7 +77,6 @@
public final class DOMAdapter implements DOM {
// Mutually exclusive casting of DOM interface to known implementations
- private DOMImpl _domImpl;
private SAXImpl _saxImpl;
private DOM _dom;
@@ -99,9 +97,7 @@
public DOMAdapter(DOM dom,
String[] namesArray,
String[] namespaceArray) {
- if (dom instanceof DOMImpl) {
- _domImpl = (DOMImpl) dom;
- } else if (dom instanceof SAXImpl){
+ if (dom instanceof SAXImpl){
_saxImpl = (SAXImpl) dom;
}
@@ -130,20 +126,16 @@
private short[] getMapping() {
if (_mapping == null) {
- if (_domImpl != null) {
- _mapping = _domImpl.getMapping(_namesArray);
- } else {
+ if (_saxImpl != null) {
_mapping = _saxImpl.getMapping(_namesArray);
- }
+ }
}
return _mapping;
}
private int[] getReverse() {
if (_reverse == null) {
- if (_domImpl != null) {
- _reverse = _domImpl.getReverseMapping(_namesArray);
- } else if (_saxImpl != null){
+ if (_saxImpl != null) {
_reverse = _saxImpl.getReverseMapping(_namesArray);
}
}
@@ -152,9 +144,7 @@
private short[] getNSMapping() {
if (_NSmapping == null) {
- if (_domImpl != null) {
- _NSmapping = _domImpl.getNamespaceMapping(_namespaceArray);
- } else {
+ if (_saxImpl != null) {
_NSmapping = _saxImpl.getNamespaceMapping(_namespaceArray);
}
}
@@ -163,10 +153,7 @@
private short[] getNSReverse() {
if (_NSreverse == null) {
- if (_domImpl != null) {
- _NSreverse =
- _domImpl.getReverseNamespaceMapping(_namespaceArray);
- } else {
+ if (_saxImpl != null) {
_NSreverse =
_saxImpl.getReverseNamespaceMapping(_namespaceArray);
}
@@ -217,9 +204,6 @@
if (_saxImpl != null) {
return _saxImpl.getTypedChildren(reverse[type]);
}
- else if (_domImpl != null) {
- return _domImpl.getTypedChildren(reverse[type]);
- }
else {
return _dom.getTypedChildren(type);
}
@@ -275,8 +259,6 @@
}
} else if (_saxImpl != null) {
return _saxImpl.getTypedAxisIterator(axis, reverse[type]);
- } else if (_domImpl != null) {
- return _domImpl.getTypedAxisIterator(axis, reverse[type]);
} else {
return _dom.getTypedAxisIterator(axis, type);
}
@@ -442,18 +424,16 @@
public void setDocumentURI(String uri)
{
- if (_domImpl != null)
- _domImpl.setDocumentURI(uri);
- else
+ if (_saxImpl != null)
_saxImpl.setDocumentURI(uri);
}
- public String getDocumentURI()
+ public String getDocumentURI()
{
- if (_domImpl != null)
- return _domImpl.getDocumentURI();
- else
+ if (_saxImpl != null)
return _saxImpl.getDocumentURI();
+ else
+ return "";
}
public String getDocumentURI(int node)
1.1.2.7 +3 -15 xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/DOMWSFilter.java
Index: DOMWSFilter.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/DOMWSFilter.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- DOMWSFilter.java 7 Mar 2003 16:14:20 -0000 1.1.2.6
+++ DOMWSFilter.java 18 Mar 2003 16:24:32 -0000 1.1.2.7
@@ -149,20 +149,8 @@
else
type = -1;
- } else if (dtm instanceof DOMImpl) {
- DOMImpl domImpl = (DOMImpl)dtm;
- short[] mapping = (short[])m_mappings.get(dtm);
- if (mapping == null) {
- mapping = domImpl.getMapping(m_translet.getNamesArray());
- m_mappings.put(dtm, mapping);
- }
-
- int expType = domImpl.getExpandedTypeID(node);
- if (expType >= 0 && expType < mapping.length)
- type = mapping[expType];
- else
- type = -1;
- } else {
+ }
+ else {
return INHERIT;
}
1.7.10.8 +11 -8 xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java
Index: KeyIndex.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java,v
retrieving revision 1.7.10.7
retrieving revision 1.7.10.8
diff -u -r1.7.10.7 -r1.7.10.8
--- KeyIndex.java 30 Jan 2003 18:41:47 -0000 1.7.10.7
+++ KeyIndex.java 18 Mar 2003 16:24:32 -0000 1.7.10.8
@@ -90,6 +90,8 @@
* id() function.
*/
private DOM _dom;
+
+ private SAXImpl _saxImpl;
/**
* Store position after call to setMark()
@@ -146,7 +148,7 @@
final String token = (String) values.nextElement();
IntegerArray nodes = (IntegerArray) _index.get(token);
- if (nodes == null && _dom instanceof DOMImpl) {
+ if (nodes == null && _saxImpl != null && _saxImpl.hasDOMSource()) {
nodes = getDOMNodeById(token);
}
@@ -169,10 +171,8 @@
*/
public IntegerArray getDOMNodeById(String id) {
IntegerArray nodes = null;
- if (_dom instanceof DOMImpl) {
- DOMImpl domImpl = (DOMImpl)_dom;
- int node = domImpl.getElementById(id);
- int ident = domImpl.getNodeIdent(node);
+ if (_saxImpl != null) {
+ int ident = _saxImpl.getElementById(id);
if (ident != DTM.NULL) {
nodes = new IntegerArray();
_index.put(id, nodes);
@@ -210,7 +210,7 @@
final String token = (String) values.nextElement();
IntegerArray nodes = (IntegerArray) _index.get(token);
- if (nodes == null && _dom instanceof DOMImpl) {
+ if (nodes == null && _saxImpl != null && _saxImpl.hasDOMSource()) {
nodes = getDOMNodeById(token);
}
if (nodes != null && nodes.indexOf(node) >= 0) {
@@ -221,7 +221,7 @@
}
else {
IntegerArray nodes = (IntegerArray) _index.get(value);
- if (nodes == null && _dom instanceof DOMImpl) {
+ if (nodes == null && _saxImpl != null && _saxImpl.hasDOMSource()) {
nodes = getDOMNodeById(string);
}
return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
@@ -311,5 +311,8 @@
public void setDom(DOM dom) {
_dom = dom;
+ if (dom instanceof SAXImpl) {
+ _saxImpl = (SAXImpl)dom;
+ }
}
}
1.11.10.11 +2 -5 xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java
Index: LoadDocument.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java,v
retrieving revision 1.11.10.10
retrieving revision 1.11.10.11
diff -u -r1.11.10.10 -r1.11.10.11
--- LoadDocument.java 11 Mar 2003 16:25:05 -0000 1.11.10.10
+++ LoadDocument.java 18 Mar 2003 16:24:32 -0000 1.11.10.11
@@ -126,10 +126,7 @@
if (newDom instanceof SAXImpl) {
return new SingletonIterator(((SAXImpl)newDom).getDocument(),
true);
- } else {
- return new SingletonIterator(((DOMImpl)newDom).getDocument(),
- true);
- }
+ }
}
// Check if we can get the DOM from a DOMCache
1.1.2.44 +116 -9 xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java
Index: SAXImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/SAXImpl.java,v
retrieving revision 1.1.2.43
retrieving revision 1.1.2.44
diff -u -r1.1.2.43 -r1.1.2.44
--- SAXImpl.java 14 Mar 2003 20:18:55 -0000 1.1.2.43
+++ SAXImpl.java 18 Mar 2003 16:24:32 -0000 1.1.2.44
@@ -68,6 +68,7 @@
import java.util.Enumeration;
import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
import org.apache.xalan.xsltc.runtime.BasisLibrary;
import org.apache.xalan.xsltc.runtime.Hashtable;
@@ -77,6 +78,11 @@
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Entity;
+
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.apache.xml.dtm.ref.sax2dtm.SAX2DTM2;
@@ -173,6 +179,17 @@
// Object used to map TransletOutputHandler events to SAX events
private CH2TOH _ch2toh = new CH2TOH();
+ // The owning Document when the input source is DOMSource.
+ private Document _document;
+
+ // The hashtable for org.w3c.dom.Node to node id mapping.
+ // This is only used when the input is a DOMSource and the
+ // buildIdIndex flag is true.
+ private Hashtable _node2Ids = null;
+
+ // True if the input source is a DOMSource.
+ private boolean _hasDOMSource = false;
+
// The DTMManager
private XSLTCDTMManager _dtmManager;
@@ -1040,25 +1057,25 @@
/**
* Construct a SAXImpl object using the default block size.
*/
- public SAXImpl(XSLTCDTMManager mgr, Source saxSource,
+ public SAXImpl(XSLTCDTMManager mgr, Source source,
int dtmIdentity, DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing, boolean buildIdIndex)
{
- this(mgr, saxSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
+ this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
doIndexing, DEFAULT_BLOCKSIZE, buildIdIndex);
}
-
+
/**
* Construct a SAXImpl object using the given block size.
*/
- public SAXImpl(XSLTCDTMManager mgr, Source saxSource,
+ public SAXImpl(XSLTCDTMManager mgr, Source source,
int dtmIdentity, DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing, int blocksize,
boolean buildIdIndex)
{
- super(mgr, saxSource, dtmIdentity, whiteSpaceFilter, xstringfactory,
+ super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
doIndexing, blocksize, false, buildIdIndex);
_dtmManager = mgr;
@@ -1070,7 +1087,48 @@
// : size * DEFAULT_TEXT_FACTOR);
/* From DOMBuilder */
- _xmlSpaceStack[0] = DTMDefaultBase.ROOTNODE;
+ _xmlSpaceStack[0] = DTMDefaultBase.ROOTNODE;
+
+ // If the input source is DOMSource, set the _document field and
+ // create the node2Ids table.
+ if (source instanceof DOMSource) {
+ _hasDOMSource = true;
+ DOMSource domsrc = (DOMSource)source;
+ Node node = domsrc.getNode();
+ if (node instanceof Document) {
+ _document = (Document)node;
+ }
+ else {
+ _document = node.getOwnerDocument();
+ }
+ _node2Ids = new Hashtable();
+ }
+ }
+
+ /**
+ * Return the node identity for a given id String
+ *
+ * @param idString The id String
+ * @return The identity of the node whose id is the given String.
+ */
+ public int getElementById(String idString)
+ {
+ Node node = _document.getElementById(idString);
+ if (node != null) {
+ Integer id = (Integer)_node2Ids.get(node);
+ return (id != null) ? id.intValue() : DTM.NULL;
+ }
+ else {
+ return DTM.NULL;
+ }
+ }
+
+ /**
+ * Return true if the input source is DOMSource.
+ */
+ public boolean hasDOMSource()
+ {
+ return _hasDOMSource;
}
/**
@@ -1296,6 +1354,18 @@
}
+ public void startElement(String uri, String localName,
+ String qname, Attributes attributes,
+ Node node)
+ throws SAXException
+ {
+ this.startElement(uri, localName, qname, attributes);
+
+ if (m_buildIdIndex) {
+ _node2Ids.put(node, new Integer(m_parents.peek()));
+ }
+ }
+
/**
* SAX2: Receive notification of the beginning of an element.
*/
@@ -2179,7 +2249,44 @@
return idAttrsTable;
}
- public boolean compareNodeToString(int node, String value) {
- return getStringValueX(node).equals(value);
+ /**
+ * The getUnparsedEntityURI function returns the URI of the unparsed
+ * entity with the specified name in the same document as the context
+ * node (see [3.3 Unparsed Entities]). It returns the empty string if
+ * there is no such entity.
+ */
+ public String getUnparsedEntityURI(String name)
+ {
+ // Special handling for DOM input
+ if (_document != null) {
+ String uri = "";
+ DocumentType doctype = _document.getDoctype();
+ if (doctype != null) {
+ NamedNodeMap entities = doctype.getEntities();
+
+ if (entities == null) {
+ return uri;
+ }
+
+ Entity entity = (Entity) entities.getNamedItem(name);
+
+ if (entity == null) {
+ return uri;
+ }
+
+ String notationName = entity.getNotationName();
+ if (notationName != null) {
+ uri = entity.getSystemId();
+ if (uri == null) {
+ uri = entity.getPublicId();
+ }
+ }
+ }
+ return uri;
+ }
+ else {
+ return super.getUnparsedEntityURI(name);
+ }
}
+
}
1.1.2.12 +26 -18 xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/XSLTCDTMManager.java
Index: XSLTCDTMManager.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Attic/XSLTCDTMManager.java,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -u -r1.1.2.11 -r1.1.2.12
--- XSLTCDTMManager.java 3 Mar 2003 15:51:39 -0000 1.1.2.11
+++ XSLTCDTMManager.java 18 Mar 2003 16:24:32 -0000 1.1.2.12
@@ -68,8 +68,7 @@
import org.apache.xml.res.XMLErrorResources;
import org.apache.xml.res.XMLMessages;
import org.apache.xml.utils.SystemIDResolver;
-import org.apache.xml.utils.XMLStringFactory;
-import org.apache.xml.utils.XMLStringFactoryDefault;
+import org.apache.xalan.xsltc.trax.DOM2SAX;
import org.xml.sax.InputSource;
import org.xml.sax.SAXNotRecognizedException;
@@ -110,7 +109,6 @@
public static XSLTCDTMManager newInstance()
{
XSLTCDTMManager factoryImpl = new XSLTCDTMManager();
- factoryImpl.setXMLStringFactory(new XMLStringFactoryDefault());
return factoryImpl;
/*
@@ -245,31 +243,41 @@
" source: "+source.getSystemId()
);
- XMLStringFactory xstringFactory = m_xsf;
int dtmPos = getFirstFreeDTMID();
int documentID = dtmPos << IDENT_DTM_NODE_BITS;
if ((null != source) && source instanceof DOMSource)
{
- DOMImpl dtm;
+ final DOMSource domsrc = (DOMSource) source;
+ final org.w3c.dom.Node node = domsrc.getNode();
+ final DOM2SAX dom2sax = new DOM2SAX(node);
+
+ SAXImpl dtm;
if (size <= 0) {
- dtm = new DOMImpl(this, (DOMSource) source, documentID,
- whiteSpaceFilter, xstringFactory, doIndexing);
+ dtm = new SAXImpl(this, source, documentID,
+ whiteSpaceFilter, null, doIndexing, buildIdIndex);
} else {
- dtm = new DOMImpl(this, (DOMSource) source, documentID,
- whiteSpaceFilter, xstringFactory, doIndexing, size);
+ dtm = new SAXImpl(this, source, documentID,
+ whiteSpaceFilter, null, doIndexing, size, buildIdIndex);
}
+
+ dtm.setDocumentURI(source.getSystemId());
- addDTM(dtm, dtmPos);
-
- dtm.createMappings();
-
-// if (DUMPTREE)
-// {
-// dtm.dumpDTM();
-// }
-
+ addDTM(dtm, dtmPos, 0);
+
+ dom2sax.setContentHandler(dtm);
+
+ try {
+ dom2sax.parse();
+ }
+ catch (RuntimeException re) {
+ throw re;
+ }
+ catch (Exception e) {
+ throw new org.apache.xml.utils.WrappedRuntimeException(e);
+ }
+
return dtm;
}
else
No revision
No revision
1.33.2.11 +35 -39 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
Index: AbstractTranslet.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
retrieving revision 1.33.2.10
retrieving revision 1.33.2.11
diff -u -r1.33.2.10 -r1.33.2.11
--- AbstractTranslet.java 7 Mar 2003 19:05:48 -0000 1.33.2.10
+++ AbstractTranslet.java 18 Mar 2003 16:24:33 -0000 1.33.2.11
@@ -77,7 +77,6 @@
import org.apache.xalan.xsltc.TransletException;
import org.apache.xalan.xsltc.TransletOutputHandler;
import org.apache.xalan.xsltc.dom.DOMAdapter;
-import org.apache.xalan.xsltc.dom.DOMImpl;
import org.apache.xalan.xsltc.dom.KeyIndex;
import org.apache.xalan.xsltc.dom.SAXImpl;
import org.apache.xalan.xsltc.runtime.output.TransletOutputHandlerFactory;
@@ -137,12 +136,7 @@
*/
public final DOMAdapter makeDOMAdapter(DOM dom)
throws TransletException {
- if (dom instanceof DOMImpl)
- return new DOMAdapter((DOMImpl)dom, namesArray, namespaceArray);
- else if (dom instanceof SAXImpl)
- return new DOMAdapter((SAXImpl)dom, namesArray, namespaceArray);
- //BasisLibrary.runTimeError(BasisLibrary.DOM_ADAPTER_INIT_ERR);
- return null;
+ return new DOMAdapter(dom, namesArray, namespaceArray);
}
/************************************************************************
@@ -321,39 +315,41 @@
* The index contains the element node index (int) and Id value (String).
*/
private final void buildIDIndex(DOM document) {
- // %MK% %REVISIT% We can pursue another way of handling the id() function
- // %MK% %REVISIT% without using the KeyIndex, e.g. introducing a function idF()
- // %MK% %REVISIT% in BasisLibrary. We need to investigate the performance impact
- // %MK% %REVISIT% of both solutions and see which one is better.
- //
- // In the DOM case, we create an empty KeyIndex at the moment.
- // The id vs. node mapping is created later when KeyIndex.lookupId() is called.
- if (document instanceof DOMImpl) {
- buildKeyIndex(ID_INDEX_NAME, document);
- }
- else {
- final Hashtable elementsByID = document.getElementsWithIDs();
-
- if (elementsByID == null) {
- return;
- }
-
- // Given a Hashtable of DTM nodes indexed by ID attribute values,
- // loop through the table copying information to a KeyIndex
- // for the mapping from ID attribute value to DTM node
- final Enumeration idValues = elementsByID.keys();
- boolean hasIDValues = false;
-
- while (idValues.hasMoreElements()) {
- final Object idValue = idValues.nextElement();
- final int element = ((Integer)elementsByID.get(idValue)).intValue();
-
- buildKeyIndex(ID_INDEX_NAME, element, idValue);
- hasIDValues = true;
+
+ if (document instanceof SAXImpl) {
+ SAXImpl saxImpl = (SAXImpl)document;
+
+ // If the input source is DOMSource, the KeyIndex table is not
+ // built at this time. It will be built later by the lookupId()
+ // and containsId() methods of the KeyIndex class.
+ if (saxImpl.hasDOMSource()) {
+ buildKeyIndex(ID_INDEX_NAME, document);
+ return;
}
+ else {
+ final Hashtable elementsByID = saxImpl.getElementsWithIDs();
- if (hasIDValues) {
- setKeyIndexDom(ID_INDEX_NAME, document);
+ if (elementsByID == null) {
+ return;
+ }
+
+ // Given a Hashtable of DTM nodes indexed by ID attribute values,
+ // loop through the table copying information to a KeyIndex
+ // for the mapping from ID attribute value to DTM node
+ final Enumeration idValues = elementsByID.keys();
+ boolean hasIDValues = false;
+
+ while (idValues.hasMoreElements()) {
+ final Object idValue = idValues.nextElement();
+ final int element = ((Integer)elementsByID.get(idValue)).intValue();
+
+ buildKeyIndex(ID_INDEX_NAME, element, idValue);
+ hasIDValues = true;
+ }
+
+ if (hasIDValues) {
+ setKeyIndexDom(ID_INDEX_NAME, document);
+ }
}
}
}
1.35.2.19 +4 -4 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
Index: BasisLibrary.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
retrieving revision 1.35.2.18
retrieving revision 1.35.2.19
diff -u -r1.35.2.18 -r1.35.2.19
--- BasisLibrary.java 5 Mar 2003 19:23:03 -0000 1.35.2.18
+++ BasisLibrary.java 18 Mar 2003 16:24:33 -0000 1.35.2.19
@@ -84,7 +84,7 @@
import org.apache.xalan.xsltc.dom.AbsoluteIterator;
import org.apache.xalan.xsltc.dom.Axis;
import org.apache.xalan.xsltc.dom.DOMAdapter;
-import org.apache.xalan.xsltc.dom.DOMImpl;
+import org.apache.xalan.xsltc.dom.SAXImpl;
import org.apache.xalan.xsltc.dom.MultiDOM;
import org.apache.xalan.xsltc.dom.SingletonIterator;
import org.apache.xalan.xsltc.dom.StepIterator;
@@ -1176,9 +1176,9 @@
DTMDefaultBase dtm = (DTMDefaultBase)((DOMAdapter)multiDOM.getMain()).getDOMImpl();
DTMManager dtmManager = dtm.getManager();
- DOMImpl idom = (DOMImpl)dtmManager.getDTM(new DOMSource(doc), false,
+
+ SAXImpl idom = (SAXImpl)dtmManager.getDTM(new DOMSource(doc), false,
null, true, false);
-
// Create DOMAdapter and register with MultiDOM
DOMAdapter domAdapter = new DOMAdapter(idom,
translet.getNamesArray(),
No revision
No revision
1.11.2.6 +13 -2 xml-xalan/java/src/org/apache/xalan/xsltc/trax/DOM2SAX.java
Index: DOM2SAX.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/DOM2SAX.java,v
retrieving revision 1.11.2.5
retrieving revision 1.11.2.6
diff -u -r1.11.2.5 -r1.11.2.6
--- DOM2SAX.java 30 Jan 2003 18:41:50 -0000 1.11.2.5
+++ DOM2SAX.java 18 Mar 2003 16:24:33 -0000 1.11.2.6
@@ -83,6 +83,7 @@
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.AttributesImpl;
+import org.apache.xalan.xsltc.dom.SAXImpl;
public class DOM2SAX implements XMLReader, Locator {
@@ -92,6 +93,7 @@
private Node _dom = null;
private ContentHandler _sax = null;
private LexicalHandler _lex = null;
+ private SAXImpl _saxImpl = null;
private Hashtable _nsPrefixes = new Hashtable();
public DOM2SAX(Node root) {
@@ -109,6 +111,10 @@
if (handler instanceof LexicalHandler) {
_lex = (LexicalHandler) handler;
}
+
+ if (handler instanceof SAXImpl) {
+ _saxImpl = (SAXImpl)handler;
+ }
}
/**
@@ -310,7 +316,12 @@
}
// Generate SAX event to start element
- _sax.startElement(uri, localName, qname, attrs);
+ if (_saxImpl != null) {
+ _saxImpl.startElement(uri, localName, qname, attrs, node);
+ }
+ else {
+ _sax.startElement(uri, localName, qname, attrs);
+ }
// Traverse all child nodes of the element (if any)
next = node.getFirstChild();
1.37.2.20 +20 -20 xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
Index: TransformerImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
retrieving revision 1.37.2.19
retrieving revision 1.37.2.20
diff -u -r1.37.2.19 -r1.37.2.20
--- TransformerImpl.java 14 Mar 2003 19:34:35 -0000 1.37.2.19
+++ TransformerImpl.java 18 Mar 2003 16:24:33 -0000 1.37.2.20
@@ -101,7 +101,6 @@
import org.apache.xalan.xsltc.TransletOutputHandler;
import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
import org.apache.xalan.xsltc.dom.DOMBuilder;
-import org.apache.xalan.xsltc.dom.DOMImpl;
import org.apache.xalan.xsltc.dom.DOMWSFilter;
import org.apache.xalan.xsltc.dom.SAXImpl;
import org.apache.xalan.xsltc.dom.XSLTCDTMManager;
@@ -430,6 +429,7 @@
throws TransformerException {
try {
DOM dom = null;
+ SAXImpl saxImpl = null;
DTMWSFilter wsfilter;
if (_translet != null && _translet instanceof StripFilter) {
wsfilter = new DOMWSFilter(_translet);
@@ -458,34 +458,30 @@
// Create a new internal DOM and set up its builder to trap
// all content/lexical events
- XSLTCDTMManager dtmManager =
- (XSLTCDTMManager) XSLTCDTMManager.newInstance();
+ XSLTCDTMManager dtmManager = XSLTCDTMManager.newInstance();
//dtmManager.setIncremental(_isIncremental);
- dom = (SAXImpl)dtmManager.getDTM(sax, false, wsfilter, true, false,
+ saxImpl = (SAXImpl)dtmManager.getDTM(sax, false, wsfilter, true, false,
hasUserReader, 0, hasIdCall);
- final DOMBuilder builder = ((SAXImpl)dom).getBuilder();
+ //final DOMBuilder builder = ((SAXImpl)dom).getBuilder();
try {
- reader.setProperty(LEXICAL_HANDLER_PROPERTY, builder);
+ reader.setProperty(LEXICAL_HANDLER_PROPERTY, saxImpl);
}
catch (SAXException e) {
// quitely ignored
}
- reader.setContentHandler(builder);
- reader.setDTDHandler(builder);
- ((SAXImpl)dom).setDocumentURI(_sourceSystemId);
+ reader.setContentHandler(saxImpl);
+ reader.setDTDHandler(saxImpl);
+ saxImpl.setDocumentURI(_sourceSystemId);
}
else if (source instanceof DOMSource) {
- final DOMSource domsrc = (DOMSource) source;
-
// Create a new internal DTM and build it directly from DOM
- XSLTCDTMManager dtmManager =
- (XSLTCDTMManager)XSLTCDTMManager.newInstance();
+ XSLTCDTMManager dtmManager = XSLTCDTMManager.newInstance();
//dtmManager.setIncremental(_isIncremental);
- dom = (DOMImpl)dtmManager.getDTM(domsrc, false, wsfilter, true,
+ saxImpl = (SAXImpl)dtmManager.getDTM(source, false, wsfilter, true,
false, hasIdCall);
- ((DOMImpl)dom).setDocumentURI(_sourceSystemId);
+ saxImpl.setDocumentURI(_sourceSystemId);
}
// Handle StreamSource input
else if (source instanceof StreamSource) {
@@ -497,8 +493,7 @@
// Create a new internal DOM and set up its builder to trap
// all content/lexical events
- XSLTCDTMManager dtmManager =
- (XSLTCDTMManager) XSLTCDTMManager.newInstance();
+ XSLTCDTMManager dtmManager = XSLTCDTMManager.newInstance();
//dtmManager.setIncremental(_isIncremental);
@@ -517,10 +512,10 @@
ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_SOURCE_ERR);
throw new TransformerException(err.toString());
}
- dom = (SAXImpl)dtmManager.getDTM(new SAXSource(reader, input),
+ saxImpl = (SAXImpl)dtmManager.getDTM(new SAXSource(reader, input),
false, wsfilter, true,
false, hasIdCall);
- ((SAXImpl)dom).setDocumentURI(_sourceSystemId);
+ saxImpl.setDocumentURI(_sourceSystemId);
}
else if (source instanceof XSLTCSource) {
final XSLTCSource xsltcsrc = (XSLTCSource)source;
@@ -534,11 +529,16 @@
return null;
}
+ if (saxImpl != null) {
+ dom = saxImpl;
+ }
+
if (!_isIdentity) {
// Give the translet the opportunity to make a prepass of
// the document, in case it can extract useful information early
_translet.prepassDocument(dom);
}
+
return dom;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org