View Javadoc
1   /*
2    * reserved comment block
3    * DO NOT REMOVE OR ALTER!
4    */
5   /*
6    * Copyright 1999-2004 The Apache Software Foundation.
7    *
8    * Licensed under the Apache License, Version 2.0 (the "License");
9    * you may not use this file except in compliance with the License.
10   * You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  /*
21   * $Id: AdaptiveResultTreeImpl.java,v 1.2.4.1 2005/09/06 05:52:18 pvedula Exp $
22   */
23  package com.sun.org.apache.xalan.internal.xsltc.dom;
24  
25  import com.sun.org.apache.xalan.internal.xsltc.DOM;
26  import com.sun.org.apache.xalan.internal.xsltc.TransletException;
27  import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
28  import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
29  import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
30  
31  import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
32  import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
33  import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
34  import com.sun.org.apache.xml.internal.utils.XMLString;
35  
36  import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
37  
38  import javax.xml.transform.SourceLocator;
39  import org.w3c.dom.Node;
40  import org.w3c.dom.NodeList;
41  import org.xml.sax.Attributes;
42  import org.xml.sax.SAXException;
43  import org.xml.sax.helpers.AttributesImpl;
44  
45  /**
46   * AdaptiveResultTreeImpl is a adaptive DOM model for result tree fragments (RTF). It is
47   * used in the case where the RTF is likely to be pure text yet it can still be a DOM tree.
48   * It is designed for RTFs which have <xsl:call-template> or <xsl:apply-templates> in
49   * the contents. Example:
50   * <pre>
51   *    &lt;xsl:variable name = "x"&gt;
52   *      &lt;xsl:call-template name = "test"&gt;
53   *         &lt;xsl:with-param name="a" select="."/&gt;
54   *      &lt;/xsl:call-template&gt;
55   *    &lt;/xsl:variable>
56   * </pre>
57   * <p>In this example the result produced by <xsl:call-template> is likely to be a single
58   * Text node. But it can also be a DOM tree. This kind of RTF cannot be modelled by
59   * SimpleResultTreeImpl.
60   * <p>
61   * AdaptiveResultTreeImpl can be considered as a smart switcher between SimpleResultTreeImpl
62   * and SAXImpl. It treats the RTF as simple Text and uses the SimpleResultTreeImpl model
63   * at the beginning. However, if it receives a call which indicates that this is a DOM tree
64   * (e.g. startElement), it will automatically transform itself into a wrapper around a
65   * SAXImpl. In this way we can have a light-weight model when the result only contains
66   * simple text, while at the same time it still works when the RTF is a DOM tree.
67   * <p>
68   * All methods in this class are overridden to delegate the action to the wrapped SAXImpl object
69   * if it is non-null, or delegate the action to the SimpleResultTreeImpl if there is no
70   * wrapped SAXImpl.
71   * <p>
72   * %REVISIT% Can we combine this class with SimpleResultTreeImpl? I think it is possible, but
73   * it will make SimpleResultTreeImpl more expensive. I will use two separate classes at
74   * this time.
75   */
76  public class AdaptiveResultTreeImpl extends SimpleResultTreeImpl
77  {
78  
79      // Document URI index, which increases by 1 at each getDocumentURI() call.
80      private static int _documentURIIndex = 0;
81  
82      private static final String EMPTY_STRING = "".intern();
83  
84      // The SAXImpl object wrapped by this class, if the RTF is a tree.
85      private SAXImpl _dom;
86  
87      /** The following fields are only used for the nested SAXImpl **/
88  
89      // The whitespace filter
90      private DTMWSFilter _wsfilter;
91  
92      // The size of the RTF
93      private int _initSize;
94  
95      // True if we want to build the ID index table
96      private boolean _buildIdIndex;
97  
98      // The AttributeList
99      private final AttributesImpl _attributes = new AttributesImpl();
100 
101     // The element name
102     private String _openElementName;
103 
104 
105     // Create a AdaptiveResultTreeImpl
106     public AdaptiveResultTreeImpl(XSLTCDTMManager dtmManager, int documentID,
107                                   DTMWSFilter wsfilter, int initSize,
108                                   boolean buildIdIndex)
109     {
110         super(dtmManager, documentID);
111 
112         _wsfilter = wsfilter;
113         _initSize = initSize;
114         _buildIdIndex = buildIdIndex;
115     }
116 
117     // Return the DOM object wrapped in this object.
118     public DOM getNestedDOM()
119     {
120         return _dom;
121     }
122 
123     // Return the document ID
124     public int getDocument()
125     {
126         if (_dom != null) {
127             return _dom.getDocument();
128         }
129         else {
130             return super.getDocument();
131         }
132     }
133 
134     // Return the String value of the RTF
135     public String getStringValue()
136     {
137         if (_dom != null) {
138             return _dom.getStringValue();
139         }
140         else {
141             return super.getStringValue();
142         }
143     }
144 
145     public DTMAxisIterator getIterator()
146     {
147         if (_dom != null) {
148             return _dom.getIterator();
149         }
150         else {
151             return super.getIterator();
152         }
153     }
154 
155     public DTMAxisIterator getChildren(final int node)
156     {
157         if (_dom != null) {
158             return _dom.getChildren(node);
159         }
160         else {
161             return super.getChildren(node);
162         }
163     }
164 
165     public DTMAxisIterator getTypedChildren(final int type)
166     {
167         if (_dom != null) {
168             return _dom.getTypedChildren(type);
169         }
170         else {
171             return super.getTypedChildren(type);
172         }
173     }
174 
175     public DTMAxisIterator getAxisIterator(final int axis)
176     {
177         if (_dom != null) {
178             return _dom.getAxisIterator(axis);
179         }
180         else {
181             return super.getAxisIterator(axis);
182         }
183     }
184 
185     public DTMAxisIterator getTypedAxisIterator(final int axis, final int type)
186     {
187         if (_dom != null) {
188             return _dom.getTypedAxisIterator(axis, type);
189         }
190         else {
191             return super.getTypedAxisIterator(axis, type);
192         }
193     }
194 
195     public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself)
196     {
197         if (_dom != null) {
198             return _dom.getNthDescendant(node, n, includeself);
199         }
200         else {
201             return super.getNthDescendant(node, n, includeself);
202         }
203     }
204 
205     public DTMAxisIterator getNamespaceAxisIterator(final int axis, final int ns)
206     {
207         if (_dom != null) {
208             return _dom.getNamespaceAxisIterator(axis, ns);
209         }
210         else {
211             return super.getNamespaceAxisIterator(axis, ns);
212         }
213     }
214 
215     public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int returnType,
216                                              String value, boolean op)
217     {
218         if (_dom != null) {
219             return _dom.getNodeValueIterator(iter, returnType, value, op);
220         }
221         else {
222             return super.getNodeValueIterator(iter, returnType, value, op);
223         }
224     }
225 
226     public DTMAxisIterator orderNodes(DTMAxisIterator source, int node)
227     {
228         if (_dom != null) {
229             return _dom.orderNodes(source, node);
230         }
231         else {
232             return super.orderNodes(source, node);
233         }
234     }
235 
236     public String getNodeName(final int node)
237     {
238         if (_dom != null) {
239             return _dom.getNodeName(node);
240         }
241         else {
242             return super.getNodeName(node);
243         }
244     }
245 
246     public String getNodeNameX(final int node)
247     {
248         if (_dom != null) {
249             return _dom.getNodeNameX(node);
250         }
251         else {
252             return super.getNodeNameX(node);
253         }
254     }
255 
256     public String getNamespaceName(final int node)
257     {
258         if (_dom != null) {
259             return _dom.getNamespaceName(node);
260         }
261         else {
262             return super.getNamespaceName(node);
263         }
264     }
265 
266     // Return the expanded type id of a given node
267     public int getExpandedTypeID(final int nodeHandle)
268     {
269         if (_dom != null) {
270             return _dom.getExpandedTypeID(nodeHandle);
271         }
272         else {
273             return super.getExpandedTypeID(nodeHandle);
274         }
275     }
276 
277     public int getNamespaceType(final int node)
278     {
279         if (_dom != null) {
280             return _dom.getNamespaceType(node);
281         }
282         else {
283             return super.getNamespaceType(node);
284         }
285     }
286 
287     public int getParent(final int nodeHandle)
288     {
289         if (_dom != null) {
290             return _dom.getParent(nodeHandle);
291         }
292         else {
293             return super.getParent(nodeHandle);
294         }
295     }
296 
297     public int getAttributeNode(final int gType, final int element)
298     {
299         if (_dom != null) {
300             return _dom.getAttributeNode(gType, element);
301         }
302         else {
303             return super.getAttributeNode(gType, element);
304         }
305     }
306 
307     public String getStringValueX(final int nodeHandle)
308     {
309         if (_dom != null) {
310             return _dom.getStringValueX(nodeHandle);
311         }
312         else {
313             return super.getStringValueX(nodeHandle);
314         }
315     }
316 
317     public void copy(final int node, SerializationHandler handler)
318         throws TransletException
319     {
320         if (_dom != null) {
321             _dom.copy(node, handler);
322         }
323         else {
324             super.copy(node, handler);
325         }
326     }
327 
328     public void copy(DTMAxisIterator nodes, SerializationHandler handler)
329         throws TransletException
330     {
331         if (_dom != null) {
332             _dom.copy(nodes, handler);
333         }
334         else {
335             super.copy(nodes, handler);
336         }
337     }
338 
339     public String shallowCopy(final int node, SerializationHandler handler)
340         throws TransletException
341     {
342         if (_dom != null) {
343             return _dom.shallowCopy(node, handler);
344         }
345         else {
346             return super.shallowCopy(node, handler);
347         }
348     }
349 
350     public boolean lessThan(final int node1, final int node2)
351     {
352         if (_dom != null) {
353             return _dom.lessThan(node1, node2);
354         }
355         else {
356             return super.lessThan(node1, node2);
357         }
358     }
359 
360     /**
361      * Dispatch the character content of a node to an output handler.
362      *
363      * The escape setting should be taken care of when outputting to
364      * a handler.
365      */
366     public void characters(final int node, SerializationHandler handler)
367         throws TransletException
368     {
369         if (_dom != null) {
370             _dom.characters(node, handler);
371         }
372         else {
373             super.characters(node, handler);
374         }
375     }
376 
377     public Node makeNode(int index)
378     {
379         if (_dom != null) {
380             return _dom.makeNode(index);
381         }
382         else {
383             return super.makeNode(index);
384         }
385     }
386 
387     public Node makeNode(DTMAxisIterator iter)
388     {
389         if (_dom != null) {
390             return _dom.makeNode(iter);
391         }
392         else {
393             return super.makeNode(iter);
394         }
395     }
396 
397     public NodeList makeNodeList(int index)
398     {
399         if (_dom != null) {
400             return _dom.makeNodeList(index);
401         }
402         else {
403             return super.makeNodeList(index);
404         }
405     }
406 
407     public NodeList makeNodeList(DTMAxisIterator iter)
408     {
409         if (_dom != null) {
410             return _dom.makeNodeList(iter);
411         }
412         else {
413             return super.makeNodeList(iter);
414         }
415     }
416 
417     public String getLanguage(int node)
418     {
419         if (_dom != null) {
420             return _dom.getLanguage(node);
421         }
422         else {
423             return super.getLanguage(node);
424         }
425     }
426 
427     public int getSize()
428     {
429         if (_dom != null) {
430             return _dom.getSize();
431         }
432         else {
433             return super.getSize();
434         }
435     }
436 
437     public String getDocumentURI(int node)
438     {
439         if (_dom != null) {
440             return _dom.getDocumentURI(node);
441         }
442         else {
443             return "adaptive_rtf" + _documentURIIndex++;
444         }
445     }
446 
447     public void setFilter(StripFilter filter)
448     {
449         if (_dom != null) {
450             _dom.setFilter(filter);
451         }
452         else {
453             super.setFilter(filter);
454         }
455     }
456 
457     public void setupMapping(String[] names, String[] uris, int[] types, String[] namespaces)
458     {
459         if (_dom != null) {
460             _dom.setupMapping(names, uris, types, namespaces);
461         }
462         else {
463             super.setupMapping(names, uris, types, namespaces);
464         }
465     }
466 
467     public boolean isElement(final int node)
468     {
469         if (_dom != null) {
470             return _dom.isElement(node);
471         }
472         else {
473             return super.isElement(node);
474         }
475     }
476 
477     public boolean isAttribute(final int node)
478     {
479         if (_dom != null) {
480             return _dom.isAttribute(node);
481         }
482         else {
483             return super.isAttribute(node);
484         }
485     }
486 
487     public String lookupNamespace(int node, String prefix)
488         throws TransletException
489     {
490         if (_dom != null) {
491             return _dom.lookupNamespace(node, prefix);
492         }
493         else {
494             return super.lookupNamespace(node, prefix);
495         }
496     }
497 
498     /**
499      * Return the node identity from a node handle.
500      */
501     public final int getNodeIdent(final int nodehandle)
502     {
503         if (_dom != null) {
504             return _dom.getNodeIdent(nodehandle);
505         }
506         else {
507             return super.getNodeIdent(nodehandle);
508         }
509     }
510 
511     /**
512      * Return the node handle from a node identity.
513      */
514     public final int getNodeHandle(final int nodeId)
515     {
516         if (_dom != null) {
517             return _dom.getNodeHandle(nodeId);
518         }
519         else {
520             return super.getNodeHandle(nodeId);
521         }
522     }
523 
524     public DOM getResultTreeFrag(int initialSize, int rtfType)
525     {
526         if (_dom != null) {
527             return _dom.getResultTreeFrag(initialSize, rtfType);
528         }
529         else {
530             return super.getResultTreeFrag(initialSize, rtfType);
531         }
532     }
533 
534     public SerializationHandler getOutputDomBuilder()
535     {
536         return this;
537     }
538 
539     public int getNSType(int node)
540     {
541         if (_dom != null) {
542             return _dom.getNSType(node);
543         }
544         else {
545             return super.getNSType(node);
546         }
547     }
548 
549     public String getUnparsedEntityURI(String name)
550     {
551         if (_dom != null) {
552             return _dom.getUnparsedEntityURI(name);
553         }
554         else {
555             return super.getUnparsedEntityURI(name);
556         }
557     }
558 
559     public Hashtable getElementsWithIDs()
560     {
561         if (_dom != null) {
562             return _dom.getElementsWithIDs();
563         }
564         else {
565             return super.getElementsWithIDs();
566         }
567     }
568 
569     /** Implementation of the SerializationHandler interfaces **/
570 
571     /** The code in some of the following interfaces are copied from SAXAdapter. **/
572 
573     private void maybeEmitStartElement() throws SAXException
574     {
575         if (_openElementName != null) {
576 
577            int index;
578            if ((index =_openElementName.indexOf(":")) < 0)
579                _dom.startElement(null, _openElementName, _openElementName, _attributes);
580            else {
581                 String uri =_dom.getNamespaceURI(_openElementName.substring(0,index));
582                 _dom.startElement(uri, _openElementName.substring(index+1), _openElementName, _attributes);
583            }
584 
585 
586             _openElementName = null;
587         }
588 
589     }
590 
591     // Create and initialize the wrapped SAXImpl object
592     private void prepareNewDOM() throws SAXException
593     {
594         _dom = (SAXImpl)_dtmManager.getDTM(null, true, _wsfilter,
595                                   true, false, false,
596                                   _initSize, _buildIdIndex);
597         _dom.startDocument();
598         // Flush pending Text nodes to SAXImpl
599         for (int i = 0; i < _size; i++) {
600             String str = _textArray[i];
601             _dom.characters(str.toCharArray(), 0, str.length());
602         }
603         _size = 0;
604     }
605 
606     public void startDocument() throws SAXException
607     {
608     }
609 
610     public void endDocument() throws SAXException
611     {
612         if (_dom != null) {
613             _dom.endDocument();
614         }
615         else {
616             super.endDocument();
617         }
618     }
619 
620     public void characters(String str) throws SAXException
621     {
622         if (_dom != null) {
623             characters(str.toCharArray(), 0, str.length());
624         }
625         else {
626             super.characters(str);
627         }
628     }
629 
630     public void characters(char[] ch, int offset, int length)
631         throws SAXException
632     {
633         if (_dom != null) {
634             maybeEmitStartElement();
635             _dom.characters(ch, offset, length);
636         }
637         else {
638             super.characters(ch, offset, length);
639         }
640     }
641 
642     public boolean setEscaping(boolean escape) throws SAXException
643     {
644         if (_dom != null) {
645             return _dom.setEscaping(escape);
646         }
647         else {
648             return super.setEscaping(escape);
649         }
650     }
651 
652     public void startElement(String elementName) throws SAXException
653     {
654         if (_dom == null) {
655             prepareNewDOM();
656         }
657 
658         maybeEmitStartElement();
659         _openElementName = elementName;
660         _attributes.clear();
661     }
662 
663     public void startElement(String uri, String localName, String qName)
664         throws SAXException
665     {
666         startElement(qName);
667     }
668 
669     public void startElement(String uri, String localName, String qName, Attributes attributes)
670         throws SAXException
671     {
672         startElement(qName);
673     }
674 
675     public void endElement(String elementName) throws SAXException
676     {
677         maybeEmitStartElement();
678         _dom.endElement(null, null, elementName);
679     }
680 
681     public void endElement(String uri, String localName, String qName)
682         throws SAXException
683     {
684         endElement(qName);
685     }
686 
687     public void addAttribute(String qName, String value)
688     {
689         // "prefix:localpart" or "localpart"
690         int colonpos = qName.indexOf(":");
691         String uri = EMPTY_STRING;
692         String localName = qName;
693         if (colonpos >0)
694         {
695             String prefix = qName.substring(0, colonpos);
696             localName = qName.substring(colonpos+1);
697             uri = _dom.getNamespaceURI(prefix);
698         }
699 
700         addAttribute(uri, localName, qName, "CDATA", value);
701     }
702 
703     public void addUniqueAttribute(String qName, String value, int flags)
704         throws SAXException
705     {
706         addAttribute(qName, value);
707     }
708 
709     public void addAttribute(String uri, String localName, String qname,
710             String type, String value)
711     {
712         if (_openElementName != null) {
713             _attributes.addAttribute(uri, localName, qname, type, value);
714         }
715         else {
716             BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, qname);
717         }
718     }
719 
720     public void namespaceAfterStartElement(String prefix, String uri)
721         throws SAXException
722     {
723         if (_dom == null) {
724            prepareNewDOM();
725         }
726 
727         _dom.startPrefixMapping(prefix, uri);
728     }
729 
730     public void comment(String comment) throws SAXException
731     {
732         if (_dom == null) {
733            prepareNewDOM();
734         }
735 
736         maybeEmitStartElement();
737         char[] chars = comment.toCharArray();
738         _dom.comment(chars, 0, chars.length);
739     }
740 
741     public void comment(char[] chars, int offset, int length)
742         throws SAXException
743     {
744         if (_dom == null) {
745            prepareNewDOM();
746         }
747 
748         maybeEmitStartElement();
749         _dom.comment(chars, offset, length);
750     }
751 
752     public void processingInstruction(String target, String data)
753         throws SAXException
754     {
755         if (_dom == null) {
756            prepareNewDOM();
757         }
758 
759         maybeEmitStartElement();
760         _dom.processingInstruction(target, data);
761     }
762 
763     /** Implementation of the DTM interfaces **/
764 
765     public void setFeature(String featureId, boolean state)
766     {
767         if (_dom != null) {
768             _dom.setFeature(featureId, state);
769         }
770     }
771 
772     public void setProperty(String property, Object value)
773     {
774         if (_dom != null) {
775             _dom.setProperty(property, value);
776         }
777     }
778 
779     public DTMAxisTraverser getAxisTraverser(final int axis)
780     {
781         if (_dom != null) {
782             return _dom.getAxisTraverser(axis);
783         }
784         else {
785             return super.getAxisTraverser(axis);
786         }
787     }
788 
789     public boolean hasChildNodes(int nodeHandle)
790     {
791         if (_dom != null) {
792             return _dom.hasChildNodes(nodeHandle);
793         }
794         else {
795             return super.hasChildNodes(nodeHandle);
796         }
797     }
798 
799     public int getFirstChild(int nodeHandle)
800     {
801         if (_dom != null) {
802             return _dom.getFirstChild(nodeHandle);
803         }
804         else {
805             return super.getFirstChild(nodeHandle);
806         }
807     }
808 
809     public int getLastChild(int nodeHandle)
810     {
811         if (_dom != null) {
812             return _dom.getLastChild(nodeHandle);
813         }
814         else {
815             return super.getLastChild(nodeHandle);
816         }
817     }
818 
819     public int getAttributeNode(int elementHandle, String namespaceURI, String name)
820     {
821         if (_dom != null) {
822             return _dom.getAttributeNode(elementHandle, namespaceURI, name);
823         }
824         else {
825             return super.getAttributeNode(elementHandle, namespaceURI, name);
826         }
827     }
828 
829     public int getFirstAttribute(int nodeHandle)
830     {
831         if (_dom != null) {
832             return _dom.getFirstAttribute(nodeHandle);
833         }
834         else {
835             return super.getFirstAttribute(nodeHandle);
836         }
837     }
838 
839     public int getFirstNamespaceNode(int nodeHandle, boolean inScope)
840     {
841         if (_dom != null) {
842             return _dom.getFirstNamespaceNode(nodeHandle, inScope);
843         }
844         else {
845             return super.getFirstNamespaceNode(nodeHandle, inScope);
846         }
847     }
848 
849     public int getNextSibling(int nodeHandle)
850     {
851         if (_dom != null) {
852             return _dom.getNextSibling(nodeHandle);
853         }
854         else {
855             return super.getNextSibling(nodeHandle);
856         }
857      }
858 
859     public int getPreviousSibling(int nodeHandle)
860     {
861         if (_dom != null) {
862             return _dom.getPreviousSibling(nodeHandle);
863         }
864         else {
865             return super.getPreviousSibling(nodeHandle);
866         }
867      }
868 
869     public int getNextAttribute(int nodeHandle)
870     {
871         if (_dom != null) {
872             return _dom.getNextAttribute(nodeHandle);
873         }
874         else {
875             return super.getNextAttribute(nodeHandle);
876         }
877     }
878 
879     public int getNextNamespaceNode(int baseHandle, int namespaceHandle,
880                                   boolean inScope)
881     {
882         if (_dom != null) {
883             return _dom.getNextNamespaceNode(baseHandle, namespaceHandle, inScope);
884         }
885         else {
886             return super.getNextNamespaceNode(baseHandle, namespaceHandle, inScope);
887         }
888     }
889 
890     public int getOwnerDocument(int nodeHandle)
891     {
892         if (_dom != null) {
893             return _dom.getOwnerDocument(nodeHandle);
894         }
895         else {
896             return super.getOwnerDocument(nodeHandle);
897         }
898     }
899 
900     public int getDocumentRoot(int nodeHandle)
901     {
902         if (_dom != null) {
903             return _dom.getDocumentRoot(nodeHandle);
904         }
905         else {
906             return super.getDocumentRoot(nodeHandle);
907         }
908     }
909 
910     public XMLString getStringValue(int nodeHandle)
911     {
912         if (_dom != null) {
913             return _dom.getStringValue(nodeHandle);
914         }
915         else {
916             return super.getStringValue(nodeHandle);
917         }
918     }
919 
920     public int getStringValueChunkCount(int nodeHandle)
921     {
922         if (_dom != null) {
923             return _dom.getStringValueChunkCount(nodeHandle);
924         }
925         else {
926             return super.getStringValueChunkCount(nodeHandle);
927         }
928     }
929 
930     public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
931                                     int[] startAndLen)
932     {
933         if (_dom != null) {
934             return _dom.getStringValueChunk(nodeHandle, chunkIndex, startAndLen);
935         }
936         else {
937             return super.getStringValueChunk(nodeHandle, chunkIndex, startAndLen);
938         }
939     }
940 
941     public int getExpandedTypeID(String namespace, String localName, int type)
942     {
943         if (_dom != null) {
944             return _dom.getExpandedTypeID(namespace, localName, type);
945         }
946         else {
947             return super.getExpandedTypeID(namespace, localName, type);
948         }
949     }
950 
951     public String getLocalNameFromExpandedNameID(int ExpandedNameID)
952     {
953         if (_dom != null) {
954             return _dom.getLocalNameFromExpandedNameID(ExpandedNameID);
955         }
956         else {
957             return super.getLocalNameFromExpandedNameID(ExpandedNameID);
958         }
959     }
960 
961     public String getNamespaceFromExpandedNameID(int ExpandedNameID)
962     {
963         if (_dom != null) {
964             return _dom.getNamespaceFromExpandedNameID(ExpandedNameID);
965         }
966         else {
967             return super.getNamespaceFromExpandedNameID(ExpandedNameID);
968         }
969     }
970 
971     public String getLocalName(int nodeHandle)
972     {
973         if (_dom != null) {
974             return _dom.getLocalName(nodeHandle);
975         }
976         else {
977             return super.getLocalName(nodeHandle);
978         }
979     }
980 
981     public String getPrefix(int nodeHandle)
982     {
983         if (_dom != null) {
984             return _dom.getPrefix(nodeHandle);
985         }
986         else {
987             return super.getPrefix(nodeHandle);
988         }
989     }
990 
991     public String getNamespaceURI(int nodeHandle)
992     {
993         if (_dom != null) {
994             return _dom.getNamespaceURI(nodeHandle);
995         }
996         else {
997             return super.getNamespaceURI(nodeHandle);
998         }
999     }
1000 
1001     public String getNodeValue(int nodeHandle)
1002     {
1003         if (_dom != null) {
1004             return _dom.getNodeValue(nodeHandle);
1005         }
1006         else {
1007             return super.getNodeValue(nodeHandle);
1008         }
1009     }
1010 
1011     public short getNodeType(int nodeHandle)
1012     {
1013         if (_dom != null) {
1014             return _dom.getNodeType(nodeHandle);
1015         }
1016         else {
1017             return super.getNodeType(nodeHandle);
1018         }
1019     }
1020 
1021     public short getLevel(int nodeHandle)
1022     {
1023         if (_dom != null) {
1024             return _dom.getLevel(nodeHandle);
1025         }
1026         else {
1027             return super.getLevel(nodeHandle);
1028         }
1029     }
1030 
1031     public boolean isSupported(String feature, String version)
1032     {
1033         if (_dom != null) {
1034             return _dom.isSupported(feature, version);
1035         }
1036         else {
1037             return super.isSupported(feature, version);
1038         }
1039     }
1040 
1041     public String getDocumentBaseURI()
1042     {
1043         if (_dom != null) {
1044             return _dom.getDocumentBaseURI();
1045         }
1046         else {
1047             return super.getDocumentBaseURI();
1048         }
1049     }
1050 
1051     public void setDocumentBaseURI(String baseURI)
1052     {
1053         if (_dom != null) {
1054             _dom.setDocumentBaseURI(baseURI);
1055         }
1056         else {
1057             super.setDocumentBaseURI(baseURI);
1058         }
1059     }
1060 
1061     public String getDocumentSystemIdentifier(int nodeHandle)
1062     {
1063         if (_dom != null) {
1064             return _dom.getDocumentSystemIdentifier(nodeHandle);
1065         }
1066         else {
1067             return super.getDocumentSystemIdentifier(nodeHandle);
1068         }
1069     }
1070 
1071     public String getDocumentEncoding(int nodeHandle)
1072     {
1073         if (_dom != null) {
1074             return _dom.getDocumentEncoding(nodeHandle);
1075         }
1076         else {
1077             return super.getDocumentEncoding(nodeHandle);
1078         }
1079     }
1080 
1081     public String getDocumentStandalone(int nodeHandle)
1082     {
1083         if (_dom != null) {
1084             return _dom.getDocumentStandalone(nodeHandle);
1085         }
1086         else {
1087             return super.getDocumentStandalone(nodeHandle);
1088         }
1089     }
1090 
1091     public String getDocumentVersion(int documentHandle)
1092     {
1093         if (_dom != null) {
1094             return _dom.getDocumentVersion(documentHandle);
1095         }
1096         else {
1097             return super.getDocumentVersion(documentHandle);
1098         }
1099     }
1100 
1101     public boolean getDocumentAllDeclarationsProcessed()
1102     {
1103         if (_dom != null) {
1104             return _dom.getDocumentAllDeclarationsProcessed();
1105         }
1106         else {
1107             return super.getDocumentAllDeclarationsProcessed();
1108         }
1109     }
1110 
1111     public String getDocumentTypeDeclarationSystemIdentifier()
1112     {
1113         if (_dom != null) {
1114             return _dom.getDocumentTypeDeclarationSystemIdentifier();
1115         }
1116         else {
1117             return super.getDocumentTypeDeclarationSystemIdentifier();
1118         }
1119     }
1120 
1121     public String getDocumentTypeDeclarationPublicIdentifier()
1122     {
1123         if (_dom != null) {
1124             return _dom.getDocumentTypeDeclarationPublicIdentifier();
1125         }
1126         else {
1127             return super.getDocumentTypeDeclarationPublicIdentifier();
1128         }
1129     }
1130 
1131     public int getElementById(String elementId)
1132     {
1133         if (_dom != null) {
1134             return _dom.getElementById(elementId);
1135         }
1136         else {
1137             return super.getElementById(elementId);
1138         }
1139     }
1140 
1141     public boolean supportsPreStripping()
1142     {
1143         if (_dom != null) {
1144             return _dom.supportsPreStripping();
1145         }
1146         else {
1147             return super.supportsPreStripping();
1148         }
1149     }
1150 
1151     public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle)
1152     {
1153         if (_dom != null) {
1154             return _dom.isNodeAfter(firstNodeHandle, secondNodeHandle);
1155         }
1156         else {
1157             return super.isNodeAfter(firstNodeHandle, secondNodeHandle);
1158         }
1159     }
1160 
1161     public boolean isCharacterElementContentWhitespace(int nodeHandle)
1162     {
1163         if (_dom != null) {
1164             return _dom.isCharacterElementContentWhitespace(nodeHandle);
1165         }
1166         else {
1167             return super.isCharacterElementContentWhitespace(nodeHandle);
1168         }
1169     }
1170 
1171     public boolean isDocumentAllDeclarationsProcessed(int documentHandle)
1172     {
1173         if (_dom != null) {
1174             return _dom.isDocumentAllDeclarationsProcessed(documentHandle);
1175         }
1176         else {
1177             return super.isDocumentAllDeclarationsProcessed(documentHandle);
1178         }
1179     }
1180 
1181     public boolean isAttributeSpecified(int attributeHandle)
1182     {
1183         if (_dom != null) {
1184             return _dom.isAttributeSpecified(attributeHandle);
1185         }
1186         else {
1187             return super.isAttributeSpecified(attributeHandle);
1188         }
1189     }
1190 
1191     public void dispatchCharactersEvents(int nodeHandle, org.xml.sax.ContentHandler ch,
1192                                          boolean normalize)
1193           throws org.xml.sax.SAXException
1194     {
1195         if (_dom != null) {
1196             _dom.dispatchCharactersEvents(nodeHandle,  ch, normalize);
1197         }
1198         else {
1199             super.dispatchCharactersEvents(nodeHandle, ch, normalize);
1200         }
1201     }
1202 
1203     public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
1204       throws org.xml.sax.SAXException
1205     {
1206         if (_dom != null) {
1207             _dom.dispatchToEvents(nodeHandle,  ch);
1208         }
1209         else {
1210             super.dispatchToEvents(nodeHandle, ch);
1211         }
1212     }
1213 
1214     public org.w3c.dom.Node getNode(int nodeHandle)
1215     {
1216         if (_dom != null) {
1217             return _dom.getNode(nodeHandle);
1218         }
1219         else {
1220             return super.getNode(nodeHandle);
1221         }
1222     }
1223 
1224     public boolean needsTwoThreads()
1225     {
1226         if (_dom != null) {
1227             return _dom.needsTwoThreads();
1228         }
1229         else {
1230             return super.needsTwoThreads();
1231         }
1232     }
1233 
1234     public org.xml.sax.ContentHandler getContentHandler()
1235     {
1236         if (_dom != null) {
1237             return _dom.getContentHandler();
1238         }
1239         else {
1240             return super.getContentHandler();
1241         }
1242     }
1243 
1244     public org.xml.sax.ext.LexicalHandler getLexicalHandler()
1245     {
1246         if (_dom != null) {
1247             return _dom.getLexicalHandler();
1248         }
1249         else {
1250             return super.getLexicalHandler();
1251         }
1252     }
1253 
1254     public org.xml.sax.EntityResolver getEntityResolver()
1255     {
1256         if (_dom != null) {
1257             return _dom.getEntityResolver();
1258         }
1259         else {
1260             return super.getEntityResolver();
1261         }
1262     }
1263 
1264     public org.xml.sax.DTDHandler getDTDHandler()
1265     {
1266         if (_dom != null) {
1267             return _dom.getDTDHandler();
1268         }
1269         else {
1270             return super.getDTDHandler();
1271         }
1272     }
1273 
1274     public org.xml.sax.ErrorHandler getErrorHandler()
1275     {
1276         if (_dom != null) {
1277             return _dom.getErrorHandler();
1278         }
1279         else {
1280             return super.getErrorHandler();
1281         }
1282     }
1283 
1284     public org.xml.sax.ext.DeclHandler getDeclHandler()
1285     {
1286         if (_dom != null) {
1287             return _dom.getDeclHandler();
1288         }
1289         else {
1290             return super.getDeclHandler();
1291         }
1292     }
1293 
1294     public void appendChild(int newChild, boolean clone, boolean cloneDepth)
1295     {
1296         if (_dom != null) {
1297             _dom.appendChild(newChild, clone, cloneDepth);
1298         }
1299         else {
1300             super.appendChild(newChild, clone, cloneDepth);
1301         }
1302     }
1303 
1304     public void appendTextChild(String str)
1305     {
1306         if (_dom != null) {
1307             _dom.appendTextChild(str);
1308         }
1309         else {
1310             super.appendTextChild(str);
1311         }
1312     }
1313 
1314     public SourceLocator getSourceLocatorFor(int node)
1315     {
1316         if (_dom != null) {
1317             return _dom.getSourceLocatorFor(node);
1318         }
1319         else {
1320             return super.getSourceLocatorFor(node);
1321         }
1322     }
1323 
1324     public void documentRegistration()
1325     {
1326         if (_dom != null) {
1327             _dom.documentRegistration();
1328         }
1329         else {
1330             super.documentRegistration();
1331         }
1332     }
1333 
1334     public void documentRelease()
1335     {
1336         if (_dom != null) {
1337             _dom.documentRelease();
1338         }
1339         else {
1340             super.documentRelease();
1341         }
1342     }
1343 
1344 }