19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file
49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information
59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file
69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License.
89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at
99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software
139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and
169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License.
179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: DTMDocumentImpl.java 468653 2006-10-28 07:07:05Z minchau $
209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xml.dtm.ref;
229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport javax.xml.transform.SourceLocator;
249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.dtm.DTM;
269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.dtm.DTMAxisIterator;
279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.dtm.DTMAxisTraverser;
289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.dtm.DTMManager;
299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.dtm.DTMWSFilter;
309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.FastStringBuffer;
319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.XMLString;
329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.apache.xml.utils.XMLStringFactory;
339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.xml.sax.Attributes;
359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.xml.sax.ContentHandler;
369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.xml.sax.Locator;
379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport org.xml.sax.ext.LexicalHandler;
389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/**
409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * This is the implementation of the DTM document interface.  It receives
419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * requests from an XML content handler similar to that of an XML DOM or SAX parser
429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to store information from the xml document in an array based
439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * dtm table structure.  This informtion is used later for document navigation,
449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * query, and SAX event dispatch functions. The DTM can also be used directly as a
459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * document composition model for an application.  The requests received are:
469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <ul>
479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>initiating DTM to set the doc handle</li>
489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>resetting DTM for data structure reuse</li>
499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>hinting the end of document to adjust the end of data structure pointers</li>
509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>createnodes (element, comment, text, attribute, ....)</li>
519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>hinting the end of an element to patch parent and siblings<li>
529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <li>setting application provided symbol name stringpool data structures</li>
539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * </ul>
549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>State: In progress!!</p>
559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * %REVIEW% I _think_ the SAX convention is that "no namespace" is expressed
579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * as "" rather than as null (which is the DOM's convention). What should
589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * DTM expect? What should it do with the other?
599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * <p>Origin: the implemention is a composite logic based on the DTM of XalanJ1 and
619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     DocImpl, DocumentImpl, ElementImpl, TextImpl, etc. of XalanJ2</p>
629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class DTMDocumentImpl
649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimplements DTM, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler
659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{
669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Number of lower bits used to represent node index.
689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        protected static final byte DOCHANDLE_SHIFT = 22;
699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Masks the lower order of node handle.
709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Same as {@link DTMConstructor.IDENT_NODE_DEFAULT}
719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        protected static final int NODEHANDLE_MASK = (1 << (DOCHANDLE_SHIFT + 1)) - 1;
729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Masks the higher order Document handle
739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Same as {@link DTMConstructor.IDENT_DOC_DEFAULT}
749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        protected static final int DOCHANDLE_MASK = -1 - NODEHANDLE_MASK;
759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        int m_docHandle = NULL;		 // masked document handle for this dtm document
779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        int m_docElement = NULL;	 // nodeHandle to the root of the actual dtm doc content
789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Context for parse-and-append operations
809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        int currentParent = 0;			// current parent - default is document root
819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        int previousSibling = 0;		// previous sibling - no previous sibling
829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        protected int m_currentNode = -1;		// current node
839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // The tree under construction can itself be used as
859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // the element stack, so m_elemStack isn't needed.
869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        //protected Stack m_elemStack = new Stack();	 // element stack
879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private boolean previousSiblingWasParent = false;
899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Local cache for record-at-a-time fetch
909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        int gotslot[] = new int[4];
919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // endDocument recieved?
939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private boolean done = false;
949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        boolean m_isError = false;
959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private final boolean DEBUG = false;
979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /** The document base URI. */
999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        protected String m_documentBaseURI;
1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** If we're building the model incrementally on demand, we need to
1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * be able to tell the source when to send us more data.
1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Note that if this has not been set, and you attempt to read ahead
1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * of the current build point, we'll probably throw a null-pointer
1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * exception. We could try to wait-and-retry instead, as a very poor
1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * fallback, but that has all the known problems with multithreading
1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * on multiprocessors and we Don't Want to Go There.
1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see setIncrementalSAXSource
1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private IncrementalSAXSource m_incrSAXSource=null;
1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ========= DTM data structure declarations. ==============
1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // nodes array: integer array blocks to hold the first level reference of the nodes,
1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // each reference slot is addressed by a nodeHandle index value.
1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Assumes indices are not larger than {@link NODEHANDLE_MASK}
1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ({@link DOCHANDLE_SHIFT} bits).
1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        ChunkedIntArray nodes = new ChunkedIntArray(4);
1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // text/comment table: string buffer to hold the text string values of the document,
1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // each of which is addressed by the absolute offset and length in the buffer
1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private FastStringBuffer m_char = new FastStringBuffer();
1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // Start of string currently being accumulated into m_char;
1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // needed because the string may be appended in several chunks.
1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private int m_char_current_start=0;
1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // %TBD% INITIALIZATION/STARTUP ISSUES
1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // -- Should we really be creating these, or should they be
1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // passed in from outside? Scott want to be able to share
1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // pools across multiple documents, so setting them here is
1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // probably not the right default.
1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private DTMStringPool m_localNames = new DTMStringPool();
1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private DTMStringPool m_nsNames = new DTMStringPool();
1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private DTMStringPool m_prefixNames = new DTMStringPool();
1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // %TBD% If we use the current ExpandedNameTable mapper, it
1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // needs to be bound to the NS and local name pools. Which
1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // means it needs to attach to them AFTER we've resolved their
1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // startup. Or it needs to attach to this document and
1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // retrieve them each time. Or this needs to be
1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // an interface _implemented_ by this class... which might be simplest!
1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private ExpandedNameTable m_expandedNames=
1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                new ExpandedNameTable();
1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private XMLStringFactory m_xsf;
1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Construct a DTM.
1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param documentNumber the ID number assigned to this document.
1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * It will be shifted up into the high bits and returned as part of
1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * all node ID numbers, so those IDs indicate which document they
1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * came from as well as a location within the document. It is the
1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * DTMManager's responsibility to assign a unique number to each
1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * document.
1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public DTMDocumentImpl(DTMManager mgr, int documentNumber,
1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                               DTMWSFilter whiteSpaceFilter,
1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                               XMLStringFactory xstringfactory){
1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                initDocument(documentNumber);	 // clear nodes and document handle
1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                m_xsf = xstringfactory;
1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Bind a IncrementalSAXSource to this DTM. If we discover we need nodes
1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * that have not yet been built, we will ask this object to send us more
1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * events, and it will manage interactions with its data sources.
1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Note that we do not actually build the IncrementalSAXSource, since we don't
1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * know what source it's reading from, what thread that source will run in,
1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * or when it will run.
1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param source The IncrementalSAXSource that we want to recieve events from
1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * on demand.
1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setIncrementalSAXSource(IncrementalSAXSource source)
1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_incrSAXSource=source;
1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Establish SAX-stream link so we can receive the requested data
1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    source.setContentHandler(this);
1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    source.setLexicalHandler(this);
1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Are the following really needed? IncrementalSAXSource doesn't yet
1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // support them, and they're mostly no-ops here...
1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //source.setErrorHandler(this);
1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //source.setDTDHandler(this);
1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //source.setDeclHandler(this);
1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Wrapper for ChunkedIntArray.append, to automatically update the
1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * previous sibling's "next" reference (if necessary) and periodically
1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * wake a reader who may have encountered incomplete data and entered
1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * a wait state.
1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param w0 int As in ChunkedIntArray.append
2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param w1 int As in ChunkedIntArray.append
2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param w2 int As in ChunkedIntArray.append
2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param w3 int As in ChunkedIntArray.append
2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int As in ChunkedIntArray.append
2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @see ChunkedIntArray.append
2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private final int appendNode(int w0, int w1, int w2, int w3)
2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // A decent compiler may inline this.
2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int slotnumber = nodes.appendSlot(w0, w1, w2, w3);
2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (DEBUG) System.out.println(slotnumber+": "+w0+" "+w1+" "+w2+" "+w3);
2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (previousSiblingWasParent)
2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodes.writeEntry(previousSibling,2,slotnumber);
2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                previousSiblingWasParent = false;	// Set the default; endElement overrides
2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return slotnumber;
2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ========= DTM Implementation Control Functions. ==============
2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Set an implementation dependent feature.
2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>
2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW% Do we really expect to set features on DTMs?
2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param featureId A feature URL.
2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param state true if this feature should be on, false otherwise.
2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void setFeature(String featureId, boolean state) {};
2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Set a reference pointer to the element name symbol table.
2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW% Should this really be Public? Changing it while
2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * DTM is in use would be a disaster.
2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param poolRef DTMStringPool reference to an instance of table.
2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void setLocalNameTable(DTMStringPool poolRef) {
2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                m_localNames = poolRef;
2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Get a reference pointer to the element name symbol table.
2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return DTMStringPool reference to an instance of table.
2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public DTMStringPool getLocalNameTable() {
2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                 return m_localNames;
2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         }
2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Set a reference pointer to the namespace URI symbol table.
2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW% Should this really be Public? Changing it while
2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * DTM is in use would be a disaster.
2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param poolRef DTMStringPool reference to an instance of table.
2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void setNsNameTable(DTMStringPool poolRef) {
2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                m_nsNames = poolRef;
2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Get a reference pointer to the namespace URI symbol table.
2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return DTMStringPool reference to an instance of table.
2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public DTMStringPool getNsNameTable() {
2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                 return m_nsNames;
2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         }
2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Set a reference pointer to the prefix name symbol table.
2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW% Should this really be Public? Changing it while
2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * DTM is in use would be a disaster.
2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param poolRef DTMStringPool reference to an instance of table.
2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void setPrefixNameTable(DTMStringPool poolRef) {
2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                m_prefixNames = poolRef;
2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Get a reference pointer to the prefix name symbol table.
2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return DTMStringPool reference to an instance of table.
2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public DTMStringPool getPrefixNameTable() {
2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return m_prefixNames;
2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         /**
2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          * Set a reference pointer to the content-text repository
2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          *
2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          * @param buffer FastStringBuffer reference to an instance of
2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          * buffer
2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          */
2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         void setContentBuffer(FastStringBuffer buffer) {
3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                 m_char = buffer;
3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         }
3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         /**
3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          * Get a reference pointer to the content-text repository
3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          *
3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          * @return FastStringBuffer reference to an instance of buffer
3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          */
3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         FastStringBuffer getContentBuffer() {
3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                 return m_char;
3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         }
3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** getContentHandler returns "our SAX builder" -- the thing that
3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * someone else should send SAX events to in order to extend this
3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * DTM model.
3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return null if this model doesn't respond to SAX events,
3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * "this" if the DTM object has a built-in SAX ContentHandler,
3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the IncrementalSAXSource if we're bound to one and should receive
3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the SAX stream via it for incremental build purposes...
3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public org.xml.sax.ContentHandler getContentHandler()
3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (m_incrSAXSource instanceof IncrementalSAXSource_Filter)
3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      return (ContentHandler) m_incrSAXSource;
3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      return this;
3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Return this DTM's lexical handler.
3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * %REVIEW% Should this return null if constrution already done/begun?
3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return null if this model doesn't respond to lexical SAX events,
3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * "this" if the DTM object has a built-in SAX ContentHandler,
3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the IncrementalSAXSource if we're bound to one and should receive
3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the SAX stream via it for incremental build purposes...
3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public LexicalHandler getLexicalHandler()
3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (m_incrSAXSource instanceof IncrementalSAXSource_Filter)
3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      return (LexicalHandler) m_incrSAXSource;
3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    else
3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      return this;
3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Return this DTM's EntityResolver.
3509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return null if this model doesn't respond to SAX entity ref events.
3529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public org.xml.sax.EntityResolver getEntityResolver()
3549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
3579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Return this DTM's DTDHandler.
3619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return null if this model doesn't respond to SAX dtd events.
3639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public org.xml.sax.DTDHandler getDTDHandler()
3659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
3689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Return this DTM's ErrorHandler.
3729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return null if this model doesn't respond to SAX error events.
3749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public org.xml.sax.ErrorHandler getErrorHandler()
3769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
3799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Return this DTM's DeclHandler.
3839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return null if this model doesn't respond to SAX Decl events.
3859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public org.xml.sax.ext.DeclHandler getDeclHandler()
3879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
3909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** @return true iff we're building this model incrementally (eg
3939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * we're partnered with a IncrementalSAXSource) and thus require that the
3949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * transformation and the parse run simultaneously. Guidance to the
3959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * DTMManager.
3969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
3979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean needsTwoThreads()
3989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null!=m_incrSAXSource;
4009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  //================================================================
4039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // ========= SAX2 ContentHandler methods =========
4049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // Accept SAX events, use them to build/extend the DTM tree.
4059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // Replaces the deprecated DocumentHandler interface.
4069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void characters(char[] ch, int start, int length)
4089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Actually creating the text node is handled by
4119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // processAccumulatedText(); here we just accumulate the
4129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // characters into the buffer.
4139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_char.append(ch,start,length);
4149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // Flush string accumulation into a text node
4179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private void processAccumulatedText()
4189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int len=m_char.length();
4209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if(len!=m_char_current_start)
4219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      {
4229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // The FastStringBuffer has been previously agreed upon
4239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        appendTextChild(m_char_current_start,len-m_char_current_start);
4249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        m_char_current_start=len;
4259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      }
4269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void endDocument()
4289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // May need to tell the low-level builder code to pop up a level.
4319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // There _should't_ be any significant pending text at this point.
4329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    appendEndDocument();
4339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void endElement(java.lang.String namespaceURI, java.lang.String localName,
4359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      java.lang.String qName)
4369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    processAccumulatedText();
4399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No args but we do need to tell the low-level builder code to
4409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // pop up a level.
4419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    appendEndElement();
4429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void endPrefixMapping(java.lang.String prefix)
4449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op
4479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void ignorableWhitespace(char[] ch, int start, int length)
4499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% I believe ignorable text isn't part of the DTM model...?
4529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void processingInstruction(java.lang.String target, java.lang.String data)
4549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    processAccumulatedText();
4579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% Which pools do target and data go into?
4589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setDocumentLocator(Locator locator)
4609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op for DTM
4629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void skippedEntity(java.lang.String name)
4649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    processAccumulatedText();
4679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //%TBD%
4689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void startDocument()
4709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    appendStartDocument();
4739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void startElement(java.lang.String namespaceURI, java.lang.String localName,
4759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      java.lang.String qName, Attributes atts)
4769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
4779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    processAccumulatedText();
4799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% Split prefix off qname
4819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    String prefix=null;
4829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int colon=qName.indexOf(':');
4839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if(colon>0)
4849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      prefix=qName.substring(0,colon);
4859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% Where do we pool expandedName, or is it just the union, or...
4879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**/System.out.println("Prefix="+prefix+" index="+m_prefixNames.stringToIndex(prefix));
4889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    appendStartElement(m_nsNames.stringToIndex(namespaceURI),
4899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                     m_localNames.stringToIndex(localName),
4909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                     m_prefixNames.stringToIndex(prefix)); /////// %TBD%
4919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% I'm assuming that DTM will require resequencing of
4939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // NS decls before other attrs, hence two passes are taken.
4949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% Is there an easier way to test for NSDecl?
4959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int nAtts=(atts==null) ? 0 : atts.getLength();
4969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% Countdown is more efficient if nobody cares about sequence.
4979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    for(int i=nAtts-1;i>=0;--i)
4989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      {
4999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        qName=atts.getQName(i);
5009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        if(qName.startsWith("xmlns:") || "xmlns".equals(qName))
5019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          {
5029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            prefix=null;
5039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            colon=qName.indexOf(':');
5049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            if(colon>0)
5059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              {
5069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                prefix=qName.substring(0,colon);
5079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              }
5089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            else
5099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              {
5109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // %REVEIW% Null or ""?
5119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                prefix=null; // Default prefix
5129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              }
5139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            appendNSDeclaration(
5169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                    m_prefixNames.stringToIndex(prefix),
5179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                    m_nsNames.stringToIndex(atts.getValue(i)),
5189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                    atts.getType(i).equalsIgnoreCase("ID"));
5199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          }
5209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      }
5219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    for(int i=nAtts-1;i>=0;--i)
5239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      {
5249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        qName=atts.getQName(i);
5259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        if(!(qName.startsWith("xmlns:") || "xmlns".equals(qName)))
5269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          {
5279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            // %TBD% I hate having to extract the prefix into a new
5289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            // string when we may never use it. Consider pooling whole
5299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            // qNames, which are already strings?
5309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            prefix=null;
5319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            colon=qName.indexOf(':');
5329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            if(colon>0)
5339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              {
5349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                prefix=qName.substring(0,colon);
5359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                localName=qName.substring(colon+1);
5369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              }
5379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            else
5389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              {
5399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                prefix=""; // Default prefix
5409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                localName=qName;
5419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              }
5429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            m_char.append(atts.getValue(i)); // Single-string value
5459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            int contentEnd=m_char.length();
5469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            if(!("xmlns".equals(prefix) || "xmlns".equals(qName)))
5489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson              appendAttribute(m_nsNames.stringToIndex(atts.getURI(i)),
5499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                  m_localNames.stringToIndex(localName),
5509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                  m_prefixNames.stringToIndex(prefix),
5519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                  atts.getType(i).equalsIgnoreCase("ID"),
5529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                  m_char_current_start, contentEnd-m_char_current_start);
5539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson            m_char_current_start=contentEnd;
5549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          }
5559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      }
5569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
5589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
5599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op in DTM, handled during element/attr processing?
5619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  //
5649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // LexicalHandler support. Not all SAX2 parsers support these events
5659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // but we may want to pass them through when they exist...
5669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  //
5679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void comment(char[] ch, int start, int length)
5689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
5699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    processAccumulatedText();
5719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_char.append(ch,start,length); // Single-string value
5739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    appendComment(m_char_current_start,length);
5749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_char_current_start+=length;
5759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void endCDATA()
5779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
5789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op in DTM
5809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void endDTD()
5829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
5839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op in DTM
5859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void endEntity(java.lang.String name)
5879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
5889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op in DTM
5909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void startCDATA()
5929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
5939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op in DTM
5959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void startDTD(java.lang.String name, java.lang.String publicId,
5979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      java.lang.String systemId)
5989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
5999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
6009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op in DTM
6019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
6029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void startEntity(java.lang.String name)
6039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson       throws org.xml.sax.SAXException
6049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
6059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // No-op in DTM
6069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
6079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  //================================================================
6109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // ========= Document Handler Functions =========
6119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // %REVIEW% jjk -- DocumentHandler is  SAX Level 1, and deprecated....
6129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // and this wasn't a fully compliant or declared implementation of that API
6139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // in any case. Phase out in favor of SAX2 ContentHandler/LexicalHandler
6149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
6169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Reset a dtm document to its initial (empty) state.
6179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
6189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * The DTMManager will invoke this method when the dtm is created.
6199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
6209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param documentNumber the handle for the DTM document.
6219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
6229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        final void initDocument(int documentNumber)
6239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
6249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // save masked DTM document handle
6259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                m_docHandle = documentNumber<<DOCHANDLE_SHIFT;
6269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Initialize the doc -- no parent, no next-sib
6289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.writeSlot(0,DOCUMENT_NODE,-1,-1,0);
6299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // wait for the first startElement to create the doc root node
6309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                done = false;
6319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
6329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
6349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Receive hint of the end of a document.
6359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
6369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The content handler will invoke this method only once, and it will
6379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * be the last method invoked during the parse.  The handler shall not
6389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * not invoke this method until it has either abandoned parsing
6399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * (because of an unrecoverable error) or reached the end of
6409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * input.</p>
6419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
6429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public void documentEnd()
6439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
6449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		done = true;
6459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// %TBD% may need to notice the last slot number and slot count to avoid
6469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// residual data from provious use of this DTM
6479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
6489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
6509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Receive notification of the beginning of a document.
6519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
6529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The SAX parser will invoke this method only once, before any
6539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * other methods in this interface.</p>
6549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
6559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public void reset()
6569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
6579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// %TBD% reset slot 0 to indicate ChunkedIntArray reuse or wait for
6599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		//       the next initDocument().
6609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		m_docElement = NULL;	 // reset nodeHandle to the root of the actual dtm doc content
6619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		initDocument(0);
6629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
6639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
6659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Factory method; creates an Element node in this document.
6669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
6679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * The node created will be chained according to its natural order of request
6689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
6699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
6709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The XML content handler will invoke endElement() method after all
6719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * of the element's content are processed in order to give DTM the indication
6729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * to prepare and patch up parent and sibling node pointers.</p>
6739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
6749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The following interface for createElement will use an index value corresponds
6759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * to the symbol entry in the DTMDStringPool based symbol tables.</p>
6769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
6779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param nsIndex The namespace of the node
6789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param nameIndex The element name.
6799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @see #endElement
6809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @see org.xml.sax.Attributes
6819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @return nodeHandle int of the element created
6829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
6839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createElement(int nsIndex, int nameIndex, Attributes atts)
6849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
6859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// do document root node creation here on the first element, create nodes for
6869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// this element and its attributes, store the element, namespace, and attritute
6879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// name indexes to the nodes array, keep track of the current node and parent
6889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// element used
6899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W0  High:  Namespace  Low:  Node Type
6919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w0 = (nsIndex << 16) | ELEMENT_NODE;
6929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W1: Parent
6939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w1 = currentParent;
6949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W2: Next  (initialized as 0)
6959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w2 = 0;
6969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W3: Tagname
6979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w3 = nameIndex;
6989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		//int ourslot = nodes.appendSlot(w0, w1, w2, w3);
6999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int ourslot = appendNode(w0, w1, w2, w3);
7009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		currentParent = ourslot;
7019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		previousSibling = 0;
7029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		setAttributes(atts);
7039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// set the root element pointer when creating the first element node
7059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		if (m_docElement == NULL)
7069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			m_docElement = ourslot;
7079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return (m_docHandle | ourslot);
7089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
7099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// Factory method to create an Element node not associated with a given name space
7119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// using String value parameters passed in from a content handler or application
7129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
7139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Factory method; creates an Element node not associated with a given name space in this document.
7149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * The node created will be chained according to its natural order of request
7169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
7179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The XML content handler or application will invoke endElement() method after all
7199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * of the element's content are processed in order to give DTM the indication
7209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * to prepare and patch up parent and sibling node pointers.</p>
7219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The following parameters for createElement contains raw string values for name
7239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * symbols used in an Element node.</p>
7249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param name String the element name, including the prefix if any.
7269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param atts The attributes attached to the element, if any.
7279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @see #endElement
7289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @see org.xml.sax.Attributes
7299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
7309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createElement(String name, Attributes atts)
7319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
7329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// This method wraps around the index valued interface of the createElement interface.
7339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// The raw string values are stored into the current DTM name symbol tables.  The method
7349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// method will then use the index values returned to invoke the other createElement()
7359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// onverted to index values modified to match a
7369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// method.
7379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int nsIndex = NULL;
7389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int nameIndex = m_localNames.stringToIndex(name);
7399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// note - there should be no prefix separator in the name because it is not associated
7409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// with a name space
7419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return createElement(nsIndex, nameIndex, atts);
7439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
7449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// Factory method to create an Element node associated with a given name space
7469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// using String value parameters passed in from a content handler or application
7479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
7489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Factory method; creates an Element node associated with a given name space in this document.
7499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * The node created will be chained according to its natural order of request
7519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
7529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The XML content handler or application will invoke endElement() method after all
7549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * of the element's content are processed in order to give DTM the indication
7559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * to prepare and patch up parent and sibling node pointers.</p>
7569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The following parameters for createElementNS contains raw string values for name
7589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * symbols used in an Element node.</p>
7599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param ns String the namespace of the node
7619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param name String the element name, including the prefix if any.
7629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param atts The attributes attached to the element, if any.
7639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @see #endElement
7649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @see org.xml.sax.Attributes
7659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
7669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createElementNS(String ns, String name, Attributes atts)
7679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
7689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// This method wraps around the index valued interface of the createElement interface.
7699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// The raw string values are stored into the current DTM name symbol tables.  The method
7709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// method will then use the index values returned to invoke the other createElement()
7719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// onverted to index values modified to match a
7729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// method.
7739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int nsIndex = m_nsNames.stringToIndex(ns);
7749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int nameIndex = m_localNames.stringToIndex(name);
7759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// The prefixIndex is not needed by the indexed interface of the createElement method
7769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int prefixSep = name.indexOf(":");
7779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int prefixIndex = m_prefixNames.stringToIndex(name.substring(0, prefixSep));
7789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return createElement(nsIndex, nameIndex, atts);
7799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
7809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
7829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Receive an indication for the end of an element.
7839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>The XML content handler will invoke this method at the end of every
7859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * element in the XML document to give hint its time to pop up the current
7869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * element and parent and patch up parent and sibling pointers if necessary
7879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
7889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * <p>%tbd% The following interface may need to be modified to match a
7899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * coordinated access to the DTMDStringPool based symbol tables.</p>
7909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		 *
7919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param ns the namespace of the element
7929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param name The element name
7939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
7949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public void endElement(String ns, String name)
7959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
7969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// pop up the stacks
7979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		//
7999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		if (previousSiblingWasParent)
8009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			nodes.writeEntry(previousSibling, 2, NULL);
8019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// Pop parentage
8039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		previousSibling = currentParent;
8049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		nodes.readSlot(currentParent, gotslot);
8059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		currentParent = gotslot[1] & 0xFFFF;
8069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// The element just being finished will be
8089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// the previous sibling for the next operation
8099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		previousSiblingWasParent = true;
8109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// Pop a level of namespace table
8129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// namespaceTable.removeLastElem();
8139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
8149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
8169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Creates attributes for the current node.
8179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
8189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param atts Attributes to be created.
8199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
8209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	void setAttributes(Attributes atts) {
8219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int atLength = (null == atts) ? 0 : atts.getLength();
8229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		for (int i=0; i < atLength; i++) {
8239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			String qname = atts.getQName(i);
8249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			createAttribute(atts.getQName(i), atts.getValue(i));
8259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		}
8269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
8279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
8299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Appends an attribute to the document.
8309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param qname Qualified Name of the attribute
8319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param value Value of the attribute
8329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @return Handle of node
8339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
8349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createAttribute(String qname, String value) {
8359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int colonpos = qname.indexOf(":");
8369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		String attName = qname.substring(colonpos+1);
8379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w0 = 0;
8389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		if (colonpos > 0) {
8399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			String prefix = qname.substring(0, colonpos);
8409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			if (prefix.equals("xml")) {
8419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 				//w0 = ATTRIBUTE_NODE |
8429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 				//	(org.apache.xalan.templates.Constants.S_XMLNAMESPACEURI << 16);
8439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			} else {
8449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 				//w0 = ATTRIBUTE_NODE |
8459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			}
8469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		} else {
8479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 			w0 = ATTRIBUTE_NODE;
8489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		}
8499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W1:  Parent
8509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w1 = currentParent;
8519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W2:  Next (not yet resolved)
8529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w2 = 0;
8539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W3:  Tag name
8549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w3 = m_localNames.stringToIndex(attName);
8559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// Add node
8569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int ourslot = appendNode(w0, w1, w2, w3);
8579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		previousSibling = ourslot;	// Should attributes be previous siblings
8589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W0: Node Type
8609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		w0 = TEXT_NODE;
8619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W1: Parent
8629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		w1 = ourslot;
8639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W2: Start Position within buffer
8649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		w2 = m_char.length();
8659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		m_char.append(value);
8669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W3: Length
8679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		w3 = m_char.length() - w2;
8689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		appendNode(w0, w1, w2, w3);
8699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		charStringStart=m_char.length();
8709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		charStringLength = 0;
8719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		//previousSibling = ourslot;
8729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// Attrs are Parents
8739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		previousSiblingWasParent = true;
8749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return (m_docHandle | ourslot);
8759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
8769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
8789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Factory method; creates a Text node in this document.
8799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
8809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * The node created will be chained according to its natural order of request
8819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
8829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
8839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param text String The characters text string from the XML document.
8849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @return int DTM node-number of the text node created
8859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
8869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createTextNode(String text)
8879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	throws DTMException
8889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
8899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// wraps around the index value based createTextNode method
8909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return createTextNode(text.toCharArray(), 0, text.length());
8919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
8929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
8949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Factory method; creates a Text node in this document.
8959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
8969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * The node created will be chained according to its natural order of request
8979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
8989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
8999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * %REVIEW% for text normalization issues, unless we are willing to
9009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * insist that all adjacent text must be merged before this method
9019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * is called.
9029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
9039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param ch The characters from the XML document.
9049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param start The start position in the array.
9059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param length The number of characters to read from the array.
9069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
9079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createTextNode(char ch[], int start, int length)
9089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	throws DTMException
9099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
9109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		m_char.append(ch, start, length);		// store the chunk to the text/comment string table
9119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// create a Text Node
9139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// %TBD% may be possible to combine with appendNode()to replace the next chunk of code
9149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w0 = TEXT_NODE;
9159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W1: Parent
9169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w1 = currentParent;
9179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W2: Start position within m_char
9189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w2 = charStringStart;
9199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W3: Length of the full string
9209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w3 = length;
9219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int ourslot = appendNode(w0, w1, w2, w3);
9229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		previousSibling = ourslot;
9239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		charStringStart=m_char.length();
9259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		charStringLength = 0;
9269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return (m_docHandle | ourslot);
9279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
9289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
9309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Factory method; creates a Comment node in this document.
9319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
9329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * The node created will be chained according to its natural order of request
9339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
9349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
9359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param text String The characters text string from the XML document.
9369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @return int DTM node-number of the text node created
9379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
9389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createComment(String text)
9399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	throws DTMException
9409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
9419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// wraps around the index value based createTextNode method
9429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return createComment(text.toCharArray(), 0, text.length());
9439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
9449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	/**
9469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * Factory method; creates a Comment node in this document.
9479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
9489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * The node created will be chained according to its natural order of request
9499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * received.  %TBD% It can be rechained later via the optional DTM writable interface.
9509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 *
9519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param ch An array holding the characters in the comment.
9529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param start The starting position in the array.
9539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @param length The number of characters to use from the array.
9549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 * @see DTMException
9559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	 */
9569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	public int createComment(char ch[], int start, int length)
9579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	throws DTMException
9589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	{
9599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		m_char.append(ch, start, length);		// store the comment string to the text/comment string table
9609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// create a Comment Node
9629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// %TBD% may be possible to combine with appendNode()to replace the next chunk of code
9639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w0 = COMMENT_NODE;
9649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W1: Parent
9659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w1 = currentParent;
9669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W2: Start position within m_char
9679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w2 = charStringStart;
9689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		// W3: Length of the full string
9699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int w3 = length;
9709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		int ourslot = appendNode(w0, w1, w2, w3);
9719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		previousSibling = ourslot;
9729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		charStringStart=m_char.length();
9749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		charStringLength = 0;
9759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 		return (m_docHandle | ourslot);
9769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	}
9779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// Counters to keep track of the current text string being accumulated with respect
9799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// to the text/comment string table: charStringStart should point to the starting
9809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// offset of the string in the table and charStringLength the acccumulated length when
9819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// appendAccumulatedText starts, and reset to the end of the table and 0 at the end
9829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	// of appendAccumulatedText for the next set of characters receives
9839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson// 	int charStringStart=0,charStringLength=0;
9849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ========= Document Navigation Functions =========
9869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
9879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /** Given a node handle, test if it has child nodes.
9889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p> %REVIEW% This is obviously useful at the DOM layer, where it
9899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * would permit testing this without having to create a proxy
9909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * node. It's less useful in the DTM API, where
9919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and
9929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * almost as self-evident. But it's a convenience, and eases porting
9939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * of DOM code to DTM.  </p>
9949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
9959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle int Handle of the node.
9969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int true if the given node has child nodes.
9979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
9989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean hasChildNodes(int nodeHandle) {
9999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return(getFirstChild(nodeHandle) != NULL);
10009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
10019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
10039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, get the handle of the node's first child.
10049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * If not yet resolved, waits for more nodes to be added to the document and
10059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * tries again.
10069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
10079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle int Handle of the node.
10089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int DTM node-number of first child, or DTM.NULL to indicate none exists.
10099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
10109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getFirstChild(int nodeHandle) {
10119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // ###shs worry about tracing/debug later
10139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
10149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Read node into variable
10159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.readSlot(nodeHandle, gotslot);
10169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // type is the last half of first slot
10189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short type = (short) (gotslot[0] & 0xFFFF);
10199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Check to see if Element or Document node
10219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if ((type == ELEMENT_NODE) || (type == DOCUMENT_NODE) ||
10229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                (type == ENTITY_REFERENCE_NODE)) {
10239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // In case when Document root is given
10259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        //	if (nodeHandle == 0) nodeHandle = 1;
10269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // %TBD% Probably was a mistake.
10279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // If someone explicitly asks for first child
10289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // of Document, I would expect them to want
10299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // that and only that.
10309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        int kid = nodeHandle + 1;
10329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodes.readSlot(kid, gotslot);
10339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        while (ATTRIBUTE_NODE == (gotslot[0] & 0xFFFF)) {
10349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                // points to next sibling
10359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                kid = gotslot[2];
10369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                // Return NULL if node has only attributes
10379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                if (kid == NULL) return NULL;
10389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                nodes.readSlot(kid, gotslot);
10399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        }
10409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // If parent slot matches given parent, return kid
10419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if (gotslot[1] == nodeHandle)
10429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        {
10439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                          int firstChild = kid | m_docHandle;
10449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                          return firstChild;
10469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        }
10479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
10489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // No child found
10499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
10519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
10529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
10549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        * Given a node handle, advance to its last child.
10559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        * If not yet resolved, waits for more nodes to be added to the document and
10569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        * tries again.
10579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        *
10589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        * @param nodeHandle int Handle of the node.
10599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        * @return int Node-number of last child,
10609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        * or DTM.NULL to indicate none exists.
10619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        */
10629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getLastChild(int nodeHandle) {
10639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // ###shs put trace/debug later
10649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
10659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // do not need to test node type since getFirstChild does that
10669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int lastChild = NULL;
10679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                for (int nextkid = getFirstChild(nodeHandle); nextkid != NULL;
10689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                nextkid = getNextSibling(nextkid)) {
10699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        lastChild = nextkid;
10709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
10719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return lastChild | m_docHandle;
10729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
10739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
10749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
10759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Retrieves an attribute node by by qualified name and namespace URI.
10769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
10779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle int Handle of the node upon which to look up this attribute.
10789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param namespaceURI The namespace URI of the attribute to
10799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   retrieve, or null.
10809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param name The local name of the attribute to
10819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   retrieve.
10829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return The attribute node handle with the specified name (
10839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
10849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   attribute.
10859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
10869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getAttributeNode(int nodeHandle, String namespaceURI, String name) {
10879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int nsIndex = m_nsNames.stringToIndex(namespaceURI),
10889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                                        nameIndex = m_localNames.stringToIndex(name);
10899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
10909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.readSlot(nodeHandle, gotslot);
10919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short type = (short) (gotslot[0] & 0xFFFF);
10929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // If nodeHandle points to element next slot would be first attribute
10939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (type == ELEMENT_NODE)
10949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodeHandle++;
10959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Iterate through Attribute Nodes
10969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                while (type == ATTRIBUTE_NODE) {
10979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if ((nsIndex == (gotslot[0] << 16)) && (gotslot[3] == nameIndex))
10989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                return nodeHandle | m_docHandle;
10999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // Goto next sibling
11009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodeHandle = gotslot[2];
11019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodes.readSlot(nodeHandle, gotslot);
11029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
11039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
11049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
11059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
11079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, get the index of the node's first attribute.
11089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
11099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle int Handle of the Element node.
11109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return Handle of first attribute, or DTM.NULL to indicate none exists.
11119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
11129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getFirstAttribute(int nodeHandle) {
11139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
11149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // %REVIEW% jjk: Just a quick observation: If you're going to
11169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // call readEntry repeatedly on the same node, it may be
11179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // more efficiently to do a readSlot to get the data locally,
11189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // reducing the addressing and call-and-return overhead.
11199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Should we check if handle is element (do we want sanity checks?)
11219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (ELEMENT_NODE != (nodes.readEntry(nodeHandle, 0) & 0xFFFF))
11229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return NULL;
11239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // First Attribute (if any) should be at next position in table
11249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle++;
11259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return(ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF)) ?
11269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle | m_docHandle : NULL;
11279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
11289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
11309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, get the index of the node's first child.
11319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * If not yet resolved, waits for more nodes to be added to the document and
11329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * tries again
11339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
11349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle handle to node, which should probably be an element
11359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *                   node, but need not be.
11369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
11379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param inScope    true if all namespaces in scope should be returned,
11389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *                   false if only the namespace declarations should be
11399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *                   returned.
11409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return handle of first namespace, or DTM.NULL to indicate none exists.
11419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
11429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getFirstNamespaceNode(int nodeHandle, boolean inScope) {
11439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
11459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
11469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
11489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, advance to its next sibling.
11499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
11509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %TBD% This currently uses the DTM-internal definition of
11519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * sibling; eg, the last attr's next sib is the first
11529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * child. In the old DTM, the DOM proxy layer provided the
11539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * additional logic for the public view.  If we're rewriting
11549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * for XPath emulation, that test must be done here.
11559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
11569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %TBD% CODE INTERACTION WITH INCREMENTAL PARSE - If not yet
11579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * resolved, should wait for more nodes to be added to the document
11589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * and tries again.
11599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
11609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle int Handle of the node.
11619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node-number of next sibling,
11629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or DTM.NULL to indicate none exists.
11639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * */
11649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getNextSibling(int nodeHandle) {
11659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
11669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Document root has no next sibling
11679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (nodeHandle == 0)
11689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return NULL;
11699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short type = (short) (nodes.readEntry(nodeHandle, 0) & 0xFFFF);
11719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if ((type == ELEMENT_NODE) || (type == ATTRIBUTE_NODE) ||
11729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                (type == ENTITY_REFERENCE_NODE)) {
11739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        int nextSib = nodes.readEntry(nodeHandle, 2);
11749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if (nextSib == NULL)
11759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                return NULL;
11769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if (nextSib != 0)
11779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                return (m_docHandle | nextSib);
11789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // ###shs should cycle/wait if nextSib is 0? Working on threading next
11799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
11809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Next Sibling is in the next position if it shares the same parent
11819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int thisParent = nodes.readEntry(nodeHandle, 1);
11829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (nodes.readEntry(++nodeHandle, 1) == thisParent)
11849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return (m_docHandle | nodeHandle);
11859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
11879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
11889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
11899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
11909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, find its preceeding sibling.
11919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * WARNING: DTM is asymmetric; this operation is resolved by search, and is
11929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * relatively expensive.
11939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
11949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
11959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node-number of the previous sib,
11969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or DTM.NULL to indicate none exists.
11979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
11989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getPreviousSibling(int nodeHandle) {
11999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
12009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Document root has no previous sibling
12019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (nodeHandle == 0)
12029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return NULL;
12039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
12049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int parent = nodes.readEntry(nodeHandle, 1);
12059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int kid = NULL;
12069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                for (int nextkid = getFirstChild(parent); nextkid != nodeHandle;
12079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                nextkid = getNextSibling(nextkid)) {
12089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        kid = nextkid;
12099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
12109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return kid | m_docHandle;
12119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
12129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
12139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
12149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, advance to the next attribute. If an
12159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * element, we advance to its first attribute; if an attr, we advance to
12169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * the next attr on the same node.
12179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
12189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle int Handle of the node.
12199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int DTM node-number of the resolved attr,
12209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or DTM.NULL to indicate none exists.
12219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
12229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getNextAttribute(int nodeHandle) {
12239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
12249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.readSlot(nodeHandle, gotslot);
12259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
12269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                //%REVIEW% Why are we using short here? There's no storage
12279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                //reduction for an automatic variable, especially one used
12289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                //so briefly, and it typically costs more cycles to process
12299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                //than an int would.
12309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short type = (short) (gotslot[0] & 0xFFFF);
12319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
12329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (type == ELEMENT_NODE) {
12339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return getFirstAttribute(nodeHandle);
12349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                } else if (type == ATTRIBUTE_NODE) {
12359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if (gotslot[2] != NULL)
12369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                return (m_docHandle | gotslot[2]);
12379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
12389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
12399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
12409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
12419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
12429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a namespace handle, advance to the next namespace.
12439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
12449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %TBD% THIS METHOD DOES NOT MATCH THE CURRENT SIGNATURE IN
12459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * THE DTM INTERFACE.  FIX IT, OR JUSTIFY CHANGING THE DTM
12469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * API.
12479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
12489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param namespaceHandle handle to node which must be of type NAMESPACE_NODE.
12499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return handle of next namespace, or DTM.NULL to indicate none exists.
12509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
12519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getNextNamespaceNode(int baseHandle,int namespaceHandle, boolean inScope) {
12529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // ###shs need to work on namespace
12539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
12549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
12559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
12569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
12579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, advance to its next descendant.
12589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * If not yet resolved, waits for more nodes to be added to the document and
12599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * tries again.
12609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
12619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param subtreeRootHandle
12629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle int Handle of the node.
12639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return handle of next descendant,
12649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or DTM.NULL to indicate none exists.
12659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
12669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getNextDescendant(int subtreeRootHandle, int nodeHandle) {
12679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                subtreeRootHandle &= NODEHANDLE_MASK;
12689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
12699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Document root [Document Node? -- jjk] - no next-sib
12709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (nodeHandle == 0)
12719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return NULL;
12729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                while (!m_isError) {
12739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // Document done and node out of bounds
12749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if (done && (nodeHandle > nodes.slotsUsed()))
12759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                break;
12769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if (nodeHandle > subtreeRootHandle) {
12779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                nodes.readSlot(nodeHandle+1, gotslot);
12789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                if (gotslot[2] != 0) {
12799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                        short type = (short) (gotslot[0] & 0xFFFF);
12809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                        if (type == ATTRIBUTE_NODE) {
12819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                nodeHandle +=2;
12829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                        } else {
12839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                int nextParentPos = gotslot[1];
12849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                if (nextParentPos >= subtreeRootHandle)
12859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                        return (m_docHandle | (nodeHandle+1));
12869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                else
12879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                        break;
12889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                        }
12899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                } else if (!done) {
12909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                        // Add wait logic here
12919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                } else
12929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                        break;
12939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        } else {
12949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                nodeHandle++;
12959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        }
12969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
12979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Probably should throw error here like original instead of returning
12989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
12999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
13009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
13029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, advance to the next node on the following axis.
13039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
13049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param axisContextHandle the start of the axis that is being traversed.
13059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle
13069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return handle of next sibling,
13079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or DTM.NULL to indicate none exists.
13089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
13099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getNextFollowing(int axisContextHandle, int nodeHandle) {
13109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                //###shs still working on
13119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
13129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
13139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
13159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, advance to the next node on the preceding axis.
13169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
13179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param axisContextHandle the start of the axis that is being traversed.
13189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
13199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node-number of preceding sibling,
13209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or DTM.NULL to indicate none exists.
13219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
13229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getNextPreceding(int axisContextHandle, int nodeHandle) {
13239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // ###shs copied from Xalan 1, what is this suppose to do?
13249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodeHandle &= NODEHANDLE_MASK;
13259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                while (nodeHandle > 1) {
13269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodeHandle--;
13279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        if (ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF))
13289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                continue;
13299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // if nodeHandle is _not_ an ancestor of
13319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // axisContextHandle, specialFind will return it.
13329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // If it _is_ an ancestor, specialFind will return -1
13339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // %REVIEW% unconditional return defeats the
13359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // purpose of the while loop -- does this
13369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        // logic make any sense?
13379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return (m_docHandle | nodes.specialFind(axisContextHandle, nodeHandle));
13399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
13409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return NULL;
13419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
13429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
13449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, find its parent node.
13459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
13469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
13479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node-number of parent,
13489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or DTM.NULL to indicate none exists.
13499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
13509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getParent(int nodeHandle) {
13519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Should check to see within range?
13529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Document Root should not have to be handled differently
13549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return (m_docHandle | nodes.readEntry(nodeHandle, 1));
13559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
13569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
13589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Returns the root element of the document.
13599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return nodeHandle to the Document Root.
13609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
13619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getDocumentRoot() {
13629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return (m_docHandle | m_docElement);
13639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
13649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
13669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, find the owning document node.
13679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
13689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node handle of document, which should always be valid.
13699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
13709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getDocument() {
13719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return m_docHandle;
13729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
13739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
13759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, find the owning document node.  This has the exact
13769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * same semantics as the DOM Document method of the same name, in that if
13779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * the nodeHandle is a document node, it will return NULL.
13789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
13799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM
13809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * binding layer. Included here as a convenience function and to
13819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * aid porting of DOM code to DTM.</p>
13829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
13839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
13849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node handle of owning document, or NULL if the nodeHandle is
13859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *             a document.
13869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
13879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getOwnerDocument(int nodeHandle) {
13889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Assumption that Document Node is always in 0 slot
13899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if ((nodeHandle & NODEHANDLE_MASK) == 0)
13909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return NULL;
13919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return (nodeHandle & DOCHANDLE_MASK);
13929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
13939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
13949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
13959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, find the owning document node.  This has the DTM
13969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * semantics; a Document node is its own owner.
13979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
13989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM
13999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * binding layer. Included here as a convenience function and to
14009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * aid porting of DOM code to DTM.</p>
14019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
14039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node handle of owning document, or NULL if the nodeHandle is
14049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *             a document.
14059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
14069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getDocumentRoot(int nodeHandle) {
14079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // Assumption that Document Node is always in 0 slot
14089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if ((nodeHandle & NODEHANDLE_MASK) == 0)
14099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        return NULL;
14109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return (nodeHandle & DOCHANDLE_MASK);
14119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
14129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
14139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
14149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Get the string-value of a node as a String object
14159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (see http://www.w3.org/TR/xpath#data-model
14169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * for the definition of a node's string-value).
14179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node ID.
14199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return A string object that represents the string-value of the given node.
14219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
14229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public XMLString getStringValue(int nodeHandle) {
14239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ###zaj - researching
14249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        nodes.readSlot(nodeHandle, gotslot);
14259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        int nodetype=gotslot[0] & 0xFF;
14269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        String value=null;
14279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
14289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        switch (nodetype) {
14299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        case TEXT_NODE:
14309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        case COMMENT_NODE:
14319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        case CDATA_SECTION_NODE:
14329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                value= m_char.getString(gotslot[2], gotslot[3]);
14339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                break;
14349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        case PROCESSING_INSTRUCTION_NODE:
14359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        case ATTRIBUTE_NODE:
14369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        case ELEMENT_NODE:
14379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        case ENTITY_REFERENCE_NODE:
14389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        default:
14399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                break;
14409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
14419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        return m_xsf.newstr( value );
14429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
14439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
14449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
14459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
14469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Get number of character array chunks in
14479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * the string-value of a node.
14489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (see http://www.w3.org/TR/xpath#data-model
14499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * for the definition of a node's string-value).
14509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Note that a single text node may have multiple text chunks.
14519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * EXPLANATION: This method is an artifact of the fact that the
14539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * underlying m_chars object may not store characters in a
14549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * single contiguous array -- for example,the current
14559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * FastStringBuffer may split a single node's text across
14569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * multiple allocation units.  This call tells us how many
14579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * separate accesses will be required to retrieve the entire
14589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * content. PLEASE NOTE that this may not be the same as the
14599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * number of SAX characters() events that caused the text node
14609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * to be built in the first place, since m_chars buffering may
14619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * be on different boundaries than the parser's buffers.
14629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node ID.
14649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return number of character array chunks in
14669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *         the string-value of a node.
14679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * */
14689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        //###zaj - tbd
14699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getStringValueChunkCount(int nodeHandle)
14709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
14719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                //###zaj    return value
14729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return 0;
14739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
14749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
14759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
14769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Get a character array chunk in the string-value of a node.
14779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (see http://www.w3.org/TR/xpath#data-model
14789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * for the definition of a node's string-value).
14799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Note that a single text node may have multiple text chunks.
14809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * EXPLANATION: This method is an artifact of the fact that
14829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * the underlying m_chars object may not store characters in a
14839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * single contiguous array -- for example,the current
14849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * FastStringBuffer may split a single node's text across
14859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * multiple allocation units.  This call retrieves a single
14869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * contiguous portion of the text -- as much as m-chars was
14879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * able to store in a single allocation unit.  PLEASE NOTE
14889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * that this may not be the same granularityas the SAX
14899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * characters() events that caused the text node to be built
14909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * in the first place, since m_chars buffering may be on
14919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * different boundaries than the parser's buffers.
14929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node ID.
14949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param chunkIndex Which chunk to get.
14959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param startAndLen An array of 2 where the start position and length of
14969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *                    the chunk will be returned.
14979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
14989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return The character array reference where the chunk occurs.  */
14999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        //###zaj - tbd
15009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
15019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                                                                                                                int[] startAndLen) {return new char[0];}
15029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
15049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return an ID that represents the node's expanded name.
15059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
15069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The handle to the node in question.
15079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
15089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the expanded-name id of the node.
15099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
15109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getExpandedTypeID(int nodeHandle) {
15119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           nodes.readSlot(nodeHandle, gotslot);
15129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String qName = m_localNames.indexToString(gotslot[3]);
15139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // Remove prefix from qName
15149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // %TBD% jjk This is assuming the elementName is the qName.
15159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           int colonpos = qName.indexOf(":");
15169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String localName = qName.substring(colonpos+1);
15179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // Get NS
15189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String namespace = m_nsNames.indexToString(gotslot[0] << 16);
15199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // Create expanded name
15209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String expandedName = namespace + ":" + localName;
15219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           int expandedNameID = m_nsNames.stringToIndex(expandedName);
15229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        return expandedNameID;
15249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
15259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
15289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given an expanded name, return an ID.  If the expanded-name does not
15299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * exist in the internal tables, the entry will be created, and the ID will
15309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * be returned.  Any additional nodes that are created that have this
15319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * expanded name will use this ID.
15329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
15339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the expanded-name id of the node.
15349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
15359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getExpandedTypeID(String namespace, String localName, int type) {
15369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // Create expanded name
15379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          // %TBD% jjk Expanded name is bitfield-encoded as
15389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          // typeID[6]nsuriID[10]localID[16]. Switch to that form, and to
15399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          // accessing the ns/local via their tables rather than confusing
15409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          // nsnames and expandednames.
15419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String expandedName = namespace + ":" + localName;
15429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           int expandedNameID = m_nsNames.stringToIndex(expandedName);
15439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           return expandedNameID;
15459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
15469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
15499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given an expanded-name ID, return the local name part.
15509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
15519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param ExpandedNameID an ID that represents an expanded-name.
15529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String Local name of this node.
15539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
15549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getLocalNameFromExpandedNameID(int ExpandedNameID) {
15559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // Get expanded name
15579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String expandedName = m_localNames.indexToString(ExpandedNameID);
15589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // Remove prefix from expanded name
15599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           int colonpos = expandedName.indexOf(":");
15609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String localName = expandedName.substring(colonpos+1);
15619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           return localName;
15629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
15639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
15669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given an expanded-name ID, return the namespace URI part.
15679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
15689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param ExpandedNameID an ID that represents an expanded-name.
15699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String URI value of this node's namespace, or null if no
15709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * namespace was resolved.
15719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        */
15729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getNamespaceFromExpandedNameID(int ExpandedNameID) {
15739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String expandedName = m_localNames.indexToString(ExpandedNameID);
15759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           // Remove local name from expanded name
15769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           int colonpos = expandedName.indexOf(":");
15779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson           String nsName = expandedName.substring(0, colonpos);
15789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        return nsName;
15809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
15819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
15849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * fixednames
15859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        */
15869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        private static final String[] fixednames=
15879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
15889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                null,null,							// nothing, Element
15899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                null,"#text",						// Attr, Text
15909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                "#cdata_section",null,	// CDATA, EntityReference
15919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                null,null,							// Entity, PI
15929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                "#comment","#document",	// Comment, Document
15939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                null,"#document-fragment", // Doctype, DocumentFragment
15949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                null};									// Notation
15959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
15969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
15979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return its DOM-style node name. This will
15989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * include names such as #text or #document.
15999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
16019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String Name of this node, which may be an empty string.
16029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW% Document when empty string is possible...
16039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
16049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getNodeName(int nodeHandle) {
16059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.readSlot(nodeHandle, gotslot);
16069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short type = (short) (gotslot[0] & 0xFFFF);
16079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                String name = fixednames[type];
16089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (null == name) {
16099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  int i=gotslot[3];
16109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  /**/System.out.println("got i="+i+" "+(i>>16)+"/"+(i&0xffff));
16119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
16129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  name=m_localNames.indexToString(i & 0xFFFF);
16139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  String prefix=m_prefixNames.indexToString(i >>16);
16149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  if(prefix!=null && prefix.length()>0)
16159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                    name=prefix+":"+name;
16169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
16179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return name;
16189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
16199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
16209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
16219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return the XPath node name.  This should be
16229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * the name as described by the XPath data model, NOT the DOM-style
16239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * name.
16249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
16269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String Name of this node.
16279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
16289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getNodeNameX(int nodeHandle) {return null;}
16299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
16309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
16319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return its DOM-style localname.
16329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (As defined in Namespaces, this is the portion of the name after any
16339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * colon character)
16349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW% What's the local name of something other than Element/Attr?
16369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Should this be DOM-style (undefined unless namespaced), or other?
16379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
16399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String Local name of this node.
16409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
16419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getLocalName(int nodeHandle) {
16429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.readSlot(nodeHandle, gotslot);
16439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short type = (short) (gotslot[0] & 0xFFFF);
16449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                String name = "";
16459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if ((type==ELEMENT_NODE) || (type==ATTRIBUTE_NODE)) {
16469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  int i=gotslot[3];
16479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  name=m_localNames.indexToString(i & 0xFFFF);
16489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  if(name==null) name="";
16499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
16509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return name;
16519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
16529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
16539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
16549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a namespace handle, return the prefix that the namespace decl is
16559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * mapping.
16569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return the prefix used to map to the namespace.
16579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p> %REVIEW% Are you sure you want "" for no prefix?  </p>
16599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW%  Should this be DOM-style (undefined unless namespaced),
16619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * or other?
16629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
16649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String prefix of this node's name, or "" if no explicit
16659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * namespace prefix was given.
16669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
16679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getPrefix(int nodeHandle) {
16689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.readSlot(nodeHandle, gotslot);
16699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short type = (short) (gotslot[0] & 0xFFFF);
16709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                String name = "";
16719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if((type==ELEMENT_NODE) || (type==ATTRIBUTE_NODE)) {
16729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  int i=gotslot[3];
16739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  name=m_prefixNames.indexToString(i >>16);
16749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                  if(name==null) name="";
16759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
16769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return name;
16779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
16789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
16799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
16809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return its DOM-style namespace URI
16819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (As defined in Namespaces, this is the declared URI which this node's
16829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * prefix -- or default in lieu thereof -- was mapped to.)
16839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the id of the node.
16859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String URI value of this node's namespace, or null if no
16869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * namespace was resolved.
16879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
16889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getNamespaceURI(int nodeHandle) {return null;}
16899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
16909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
16919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return its node value. This is mostly
16929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * as defined by the DOM, but may ignore some conveniences.
16939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>
16949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
16959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node id.
16969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String Value of this node, or null if not
16979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * meaningful for this node type.
16989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
16999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getNodeValue(int nodeHandle)
17009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
17019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                nodes.readSlot(nodeHandle, gotslot);
17029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int nodetype=gotslot[0] & 0xFF;		// ###zaj use mask to get node type
17039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                String value=null;
17049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                switch (nodetype) {			// ###zaj todo - document nodetypes
17069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                case ATTRIBUTE_NODE:
17079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodes.readSlot(nodeHandle+1, gotslot);
17089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                case TEXT_NODE:
17099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                case COMMENT_NODE:
17109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                case CDATA_SECTION_NODE:
17119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        value=m_char.getString(gotslot[2], gotslot[3]);		//###zaj
17129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        break;
17139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                case PROCESSING_INSTRUCTION_NODE:
17149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                case ELEMENT_NODE:
17159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                case ENTITY_REFERENCE_NODE:
17169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                default:
17179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        break;
17189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
17199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return value;
17209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
17219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
17239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Given a node handle, return its DOM-style node type.
17249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>
17259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * %REVIEW% Generally, returning short is false economy. Return int?
17269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
17279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node id.
17289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return int Node type, as per the DOM's Node._NODE constants.
17299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
17309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public short getNodeType(int nodeHandle) {
17319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return(short) (nodes.readEntry(nodeHandle, 0) & 0xFFFF);
17329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
17339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
17359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Get the depth level of this node in the tree (equals 1 for
17369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * a parentless node).
17379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
17389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node id.
17399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the number of ancestors, plus one
17409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @xsl.usage internal
17419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
17429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public short getLevel(int nodeHandle) {
17439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                short count = 0;
17449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                while (nodeHandle != 0) {
17459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        count++;
17469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        nodeHandle = nodes.readEntry(nodeHandle, 1);
17479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
17489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                return count;
17499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
17509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ============== Document query functions ==============
17529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
17549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Tests whether DTM DOM implementation implements a specific feature and
17559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * that feature is supported by this node.
17569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
17579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param feature The name of the feature to test.
17589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param version This is the version number of the feature to test.
17599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   If the version is not
17609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   specified, supporting any version of the feature will cause the
17619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   method to return <code>true</code>.
17629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return Returns <code>true</code> if the specified feature is
17639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   supported on this node, <code>false</code> otherwise.
17649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
17659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean isSupported(String feature, String version) {return false;}
17669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
17689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return the base URI of the document entity. If it is not known
17699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (because the document was parsed from a socket connection or from
17709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * standard input, for example), the value of this property is unknown.
17719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
17729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the document base URI String object or null if unknown.
17739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
17749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getDocumentBaseURI()
17759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
17769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          return m_documentBaseURI;
17789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
17799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
17819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Set the base URI of the document entity.
17829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
17839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param baseURI the document base URI String object or null if unknown.
17849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
17859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void setDocumentBaseURI(String baseURI)
17869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
17879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          m_documentBaseURI = baseURI;
17899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
17909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
17919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
17929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return the system identifier of the document entity. If
17939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * it is not known, the value of this property is unknown.
17949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
17959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node id, which can be any valid node handle.
17969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the system identifier String object or null if unknown.
17979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
17989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getDocumentSystemIdentifier(int nodeHandle) {return null;}
17999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return the name of the character encoding scheme
18029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        in which the document entity is expressed.
18039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node id, which can be any valid node handle.
18059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the document encoding String object.
18069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
18079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getDocumentEncoding(int nodeHandle) {return null;}
18089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return an indication of the standalone status of the document,
18119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        either "yes" or "no". This property is derived from the optional
18129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        standalone document declaration in the XML declaration at the
18139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        beginning of the document entity, and has no value if there is no
18149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        standalone document declaration.
18159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node id, which can be any valid node handle.
18179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the document standalone String object, either "yes", "no", or null.
18189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
18199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getDocumentStandalone(int nodeHandle) {return null;}
18209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return a string representing the XML version of the document. This
18239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * property is derived from the XML declaration optionally present at the
18249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * beginning of the document entity, and has no value if there is no XML
18259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * declaration.
18269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param documentHandle the document handle
18289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the document version String object
18309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
18319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getDocumentVersion(int documentHandle) {return null;}
18329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return an indication of
18359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * whether the processor has read the complete DTD. Its value is a
18369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * boolean. If it is false, then certain properties (indicated in their
18379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * descriptions below) may be unknown. If it is true, those properties
18389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * are never unknown.
18399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return <code>true</code> if all declarations were processed {};
18419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *         <code>false</code> otherwise.
18429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
18439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean getDocumentAllDeclarationsProcessed() {return false;}
18449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *   A document type declaration information item has the following properties:
18479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *     1. [system identifier] The system identifier of the external subset, if
18499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        it exists. Otherwise this property has no value.
18509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the system identifier String object, or null if there is none.
18529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
18539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getDocumentTypeDeclarationSystemIdentifier() {return null;}
18549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return the public identifier of the external subset,
18579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * normalized as described in 4.2.2 External Entities [XML]. If there is
18589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * no external subset or if it has no public identifier, this property
18599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * has no value.
18609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return the public identifier String object, or null if there is none.
18629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
18639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getDocumentTypeDeclarationPublicIdentifier() {return null;}
18649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Returns the <code>Element</code> whose <code>ID</code> is given by
18679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <code>elementId</code>. If no such element exists, returns
18689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <code>DTM.NULL</code>. Behavior is not defined if more than one element
18699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * has this <code>ID</code>. Attributes (including those
18709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * with the name "ID") are not of type ID unless so defined by DTD/Schema
18719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * information available to the DTM implementation.
18729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Implementations that do not know whether attributes are of type ID or
18739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * not are expected to return <code>DTM.NULL</code>.
18749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>%REVIEW% Presumably IDs are still scoped to a single document,
18769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * and this operation searches only within a single document, right?
18779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Wouldn't want collisions between DTMs in the same process.</p>
18789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
18799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param elementId The unique <code>id</code> value for an element.
18809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return The handle of the matching element.
18819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
18829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public int getElementById(String elementId) {return 0;}
18839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
18849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
18859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * The getUnparsedEntityURI function returns the URI of the unparsed
18869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * entity with the specified name in the same document as the context
18879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * node (see [3.3 Unparsed Entities]). It returns the empty string if
18889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * there is no such entity.
18899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>
18909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * XML processors may choose to use the System Identifier (if one
18919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * is provided) to resolve the entity, rather than the URI in the
18929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Public Identifier. The details are dependent on the processor, and
18939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * we would have to support some form of plug-in resolver to handle
18949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * this properly. Currently, we simply return the System Identifier if
18959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * present, and hope that it a usable URI or that our caller can
18969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * map it to one.
18979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * TODO: Resolve Public Identifiers... or consider changing function name.
18989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>
18999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * If we find a relative URI
19009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * reference, XML expects it to be resolved in terms of the base URI
19019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * of the document. The DOM doesn't do that for us, and it isn't
19029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * entirely clear whether that should be done here; currently that's
19039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * pushed up to a higher level of our application. (Note that DOM Level
19049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * 1 didn't store the document's base URI.)
19059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * TODO: Consider resolving Relative URIs.
19069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>
19079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * (The DOM's statement that "An XML processor may choose to
19089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * completely expand entities before the structure model is passed
19099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * to the DOM" refers only to parsed entities, not unparsed, and hence
19109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * doesn't affect this function.)
19119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param name A string containing the Entity Name of the unparsed
19139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * entity.
19149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return String containing the URI of the Unparsed Entity, or an
19169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * empty string if no such entity exists.
19179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
19189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public String getUnparsedEntityURI(String name) {return null;}
19199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ============== Boolean methods ================
19229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
19249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return true if the xsl:strip-space or xsl:preserve-space was processed
19259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * during construction of the DTM document.
19269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>%REVEIW% Presumes a 1:1 mapping from DTM to Document, since
19289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * we aren't saying which Document to query...?</p>
19299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
19309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean supportsPreStripping() {return false;}
19319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
19339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Figure out whether nodeHandle2 should be considered as being later
19349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * in the document than nodeHandle1, in Document Order as defined
19359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * by the XPath model. This may not agree with the ordering defined
19369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * by other XML applications.
19379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>
19389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * There are some cases where ordering isn't defined, and neither are
19399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * the results of this function -- though we'll generally return true.
19409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * TODO: Make sure this does the right thing with attribute nodes!!!
19429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle1 DOM Node to perform position comparison on.
19449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle2 DOM Node to perform position comparison on .
19459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return false if node2 comes before node1, otherwise return true.
19479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * You can think of this as
19489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <code>(node1.documentOrderPosition &lt;= node2.documentOrderPosition)</code>.
19499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
19509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean isNodeAfter(int nodeHandle1, int nodeHandle2) {return false;}
19519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
19539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *     2. [element content whitespace] A boolean indicating whether the
19549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        character is white space appearing within element content (see [XML],
19559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        2.10 "White Space Handling"). Note that validating XML processors are
19569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        required by XML 1.0 to provide this information. If there is no
19579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        declaration for the containing element, this property has no value for
19589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        white space characters. If no declaration has been read, but the [all
19599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        declarations processed] property of the document information item is
19609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        false (so there may be an unread declaration), then the value of this
19619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        property is unknown for white space characters. It is always false for
19629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        characters that are not white space.
19639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle the node ID.
19659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return <code>true</code> if the character data is whitespace;
19669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *         <code>false</code> otherwise.
19679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
19689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean isCharacterElementContentWhitespace(int nodeHandle) {return false;}
19699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
19719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *    10. [all declarations processed] This property is not strictly speaking
19729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        part of the infoset of the document. Rather it is an indication of
19739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        whether the processor has read the complete DTD. Its value is a
19749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        boolean. If it is false, then certain properties (indicated in their
19759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        descriptions below) may be unknown. If it is true, those properties
19769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        are never unknown.
19779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param documentHandle A node handle that must identify a document.
19799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return <code>true</code> if all declarations were processed;
19809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *         <code>false</code> otherwise.
19819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
19829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean isDocumentAllDeclarationsProcessed(int documentHandle) {return false;}
19839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
19859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *     5. [specified] A flag indicating whether this attribute was actually
19869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        specified in the start-tag of its element, or was defaulted from the
19879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *        DTD.
19889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
19899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param attributeHandle the attribute handle
19909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return <code>true</code> if the attribute was specified;
19919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *         <code>false</code> if it was defaulted.
19929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
19939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public boolean isAttributeSpecified(int attributeHandle) {return false;}
19949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ========== Direct SAX Dispatch, for optimization purposes ========
19969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
19979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
19989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Directly call the
19999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * characters method on the passed ContentHandler for the
20009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * string-value of the given node (see http://www.w3.org/TR/xpath#data-model
20019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * for the definition of a node's string-value). Multiple calls to the
20029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * ContentHandler's characters methods may well occur for a single call to
20039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * this method.
20049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node ID.
20069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param ch A non-null reference to a ContentHandler.
20079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @throws org.xml.sax.SAXException
20099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
20109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void dispatchCharactersEvents(
20119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                                                                                                                                        int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize)
20129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        throws org.xml.sax.SAXException {}
20139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
20159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Directly create SAX parser events from a subtree.
20169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node ID.
20189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param ch A non-null reference to a ContentHandler.
20199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @throws org.xml.sax.SAXException
20219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
20229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch)
20249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        throws org.xml.sax.SAXException {}
20259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
20279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Return an DOM node for the given node.
20289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param nodeHandle The node ID.
20309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @return A node representation of the DTM node.
20329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
20339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public org.w3c.dom.Node getNode(int nodeHandle)
20349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        {
20359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          return null;
20369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
20379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // ==== Construction methods (may not be supported by some implementations!) =====
20399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // %REVIEW% jjk: These probably aren't the right API. At the very least
20409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // they need to deal with current-insertion-location and end-element
20419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        // issues.
20429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
20449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Append a child to the end of the child list of the current node. Please note that the node
20459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * is always cloned if it is owned by another document.
20469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>%REVIEW% "End of the document" needs to be defined more clearly.
20489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Does it become the last child of the Document? Of the root element?</p>
20499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param newChild Must be a valid new node handle.
20519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param clone true if the child should be cloned into the document.
20529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param cloneDepth if the clone argument is true, specifies that the
20539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *                   clone should include all it's children.
20549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
20559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void appendChild(int newChild, boolean clone, boolean cloneDepth) {
20569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                boolean sameDoc = ((newChild & DOCHANDLE_MASK) == m_docHandle);
20579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (clone || !sameDoc) {
20589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                } else {
20609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                }
20629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
20639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        /**
20659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Append a text node child that will be constructed from a string,
20669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * to the end of the document.
20679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * <p>%REVIEW% "End of the document" needs to be defined more clearly.
20699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * Does it become the last child of the Document? Of the root element?</p>
20709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         *
20719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         * @param str Non-null reference to a string.
20729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson         */
20739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        public void appendTextChild(String str) {
20749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // ###shs Think more about how this differs from createTextNode
20759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson          //%TBD%
20769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson        }
20779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  //================================================================
20809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // ==== BUILDER methods ====
20819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // %TBD% jjk: SHOULD PROBABLY BE INLINED, unless we want to support
20829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  // both SAX1 and SAX2 and share this logic between them.
20839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
20849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Append a text child at the current insertion point. Assumes that the
20859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * actual content of the text has previously been appended to the m_char
20869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * buffer (shared with the builder).
20879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
20889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param m_char_current_start int Starting offset of node's content in m_char.
20899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param contentLength int Length of node's content in m_char.
20909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
20919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendTextChild(int m_char_current_start,int contentLength)
20929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
20939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // create a Text Node
20949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% may be possible to combine with appendNode()to replace the next chunk of code
20959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w0 = TEXT_NODE;
20969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W1: Parent
20979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w1 = currentParent;
20989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W2: Start position within m_char
20999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w2 = m_char_current_start;
21009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W3: Length of the full string
21019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w3 = contentLength;
21029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int ourslot = appendNode(w0, w1, w2, w3);
21049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSibling = ourslot;
21059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
21069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Append a comment child at the current insertion point. Assumes that the
21089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * actual content of the comment has previously been appended to the m_char
21099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * buffer (shared with the builder).
21109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
21119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param m_char_current_start int Starting offset of node's content in m_char.
21129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param contentLength int Length of node's content in m_char.
21139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
21149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendComment(int m_char_current_start,int contentLength)
21159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
21169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // create a Comment Node
21179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% may be possible to combine with appendNode()to replace the next chunk of code
21189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w0 = COMMENT_NODE;
21199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W1: Parent
21209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w1 = currentParent;
21219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W2: Start position within m_char
21229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w2 = m_char_current_start;
21239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W3: Length of the full string
21249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w3 = contentLength;
21259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int ourslot = appendNode(w0, w1, w2, w3);
21279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSibling = ourslot;
21289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
21299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Append an Element child at the current insertion point. This
21329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Element then _becomes_ the insertion point; subsequent appends
21339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * become its lastChild until an appendEndElement() call is made.
21349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
21359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Assumes that the symbols (local name, namespace URI and prefix)
21369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * have already been added to the pools
21379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
21389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Note that this _only_ handles the Element node itself. Attrs and
21399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * namespace nodes are unbundled in the ContentHandler layer
21409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * and appended separately.
21419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
21429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param namespaceIndex: Index within the namespaceURI string pool
21439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param localNameIndex Index within the local name string pool
21449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param prefixIndex: Index within the prefix string pool
21459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
21469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendStartElement(int namespaceIndex,int localNameIndex, int prefixIndex)
21479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
21489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // do document root node creation here on the first element, create nodes for
21499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // this element and its attributes, store the element, namespace, and attritute
21509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // name indexes to the nodes array, keep track of the current node and parent
21519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // element used
21529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // W0  High:  Namespace  Low:  Node Type
21549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int w0 = (namespaceIndex << 16) | ELEMENT_NODE;
21559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // W1: Parent
21569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int w1 = currentParent;
21579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // W2: Next  (initialized as 0)
21589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int w2 = 0;
21599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // W3: Tagname high: prefix Low: local name
21609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int w3 = localNameIndex | prefixIndex<<16;
21619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                /**/System.out.println("set w3="+w3+" "+(w3>>16)+"/"+(w3&0xffff));
21629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                //int ourslot = nodes.appendSlot(w0, w1, w2, w3);
21649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                int ourslot = appendNode(w0, w1, w2, w3);
21659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                currentParent = ourslot;
21669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                previousSibling = 0;
21679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                // set the root element pointer when creating the first element node
21699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                if (m_docElement == NULL)
21709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                        m_docElement = ourslot;
21719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
21729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Append a Namespace Declaration child at the current insertion point.
21749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Assumes that the symbols (namespace URI and prefix) have already been
21759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * added to the pools
21769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
21779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param prefixIndex: Index within the prefix string pool
21789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param namespaceIndex: Index within the namespaceURI string pool
21799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param isID: If someone really insists on writing a bad DTD, it is
21809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * theoretically possible for a namespace declaration to also be declared
21819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * as being a node ID. I don't really want to support that stupidity,
21829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * but I'm not sure we can refuse to accept it.
21839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
21849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendNSDeclaration(int prefixIndex, int namespaceIndex,
21859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                           boolean isID)
21869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
21879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %REVIEW% I'm assigning this node the "namespace for namespaces"
21889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // which the DOM defined. It is expected that the Namespace spec will
21899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // adopt this as official. It isn't strictly needed since it's implied
21909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // by the nodetype, but for now...
21919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %REVIEW% Prefix need not be recorded; it's implied too. But
21939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // recording it might simplify the design.
21949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% isID is not currently honored.
21969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    final int namespaceForNamespaces=m_nsNames.stringToIndex("http://www.w3.org/2000/xmlns/");
21989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
21999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W0  High:  Namespace  Low:  Node Type
22009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w0 = NAMESPACE_NODE | (m_nsNames.stringToIndex("http://www.w3.org/2000/xmlns/")<<16);
22019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W1:  Parent
22039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w1 = currentParent;
22049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W2:  CURRENTLY UNUSED -- It's next-sib in attrs, but we have no kids.
22059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w2 = 0;
22069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W3:  namespace name
22079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w3 = namespaceIndex;
22089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Add node
22099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int ourslot = appendNode(w0, w1, w2, w3);
22109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSibling = ourslot;	// Should attributes be previous siblings
22119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSiblingWasParent = false;
22129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return ;//(m_docHandle | ourslot);
22139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
22149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Append an Attribute child at the current insertion
22169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * point.  Assumes that the symbols (namespace URI, local name, and
22179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * prefix) have already been added to the pools, and that the content has
22189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * already been appended to m_char. Note that the attribute's content has
22199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * been flattened into a single string; DTM does _NOT_ attempt to model
22209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the details of entity references within attribute values.
22219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
22229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param namespaceIndex int Index within the namespaceURI string pool
22239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param localNameIndex int Index within the local name string pool
22249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param prefixIndex int Index within the prefix string pool
22259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param isID boolean True if this attribute was declared as an ID
22269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * (for use in supporting getElementByID).
22279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param m_char_current_start int Starting offset of node's content in m_char.
22289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param contentLength int Length of node's content in m_char.
22299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
22309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendAttribute(int namespaceIndex, int localNameIndex, int prefixIndex,
22319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                       boolean isID,
22329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                       int m_char_current_start, int contentLength)
22339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
22349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% isID is not currently honored.
22359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W0  High:  Namespace  Low:  Node Type
22379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w0 = ATTRIBUTE_NODE | namespaceIndex<<16;
22389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W1:  Parent
22409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w1 = currentParent;
22419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W2:  Next (not yet resolved)
22429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w2 = 0;
22439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W3:  Tagname high: prefix Low: local name
22449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int w3 = localNameIndex | prefixIndex<<16;
22459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    /**/System.out.println("set w3="+w3+" "+(w3>>16)+"/"+(w3&0xffff));
22469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Add node
22479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int ourslot = appendNode(w0, w1, w2, w3);
22489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSibling = ourslot;	// Should attributes be previous siblings
22499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Attribute's content is currently appended as a Text Node
22519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W0: Node Type
22539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    w0 = TEXT_NODE;
22549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W1: Parent
22559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    w1 = ourslot;
22569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W2: Start Position within buffer
22579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    w2 = m_char_current_start;
22589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // W3: Length
22599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    w3 = contentLength;
22609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    appendNode(w0, w1, w2, w3);
22619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Attrs are Parents
22639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSiblingWasParent = true;
22649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return ;//(m_docHandle | ourslot);
22659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
22669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
22689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This returns a stateless "traverser", that can navigate over an
22699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * XPath axis, though not in document order.
22709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
22719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param axis One of Axes.ANCESTORORSELF, etc.
22729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
22739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return A DTMAxisIterator, or null if the given axis isn't supported.
22749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
22759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public DTMAxisTraverser getAxisTraverser(final int axis)
22769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
22779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
22789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
22799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
22819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This is a shortcut to the iterators that implement the
22829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * supported XPath axes (only namespace::) is not supported.
22839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns a bare-bones iterator that must be initialized
22849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * with a start node (using iterator.setStartNode()).
22859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
22869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param axis One of Axes.ANCESTORORSELF, etc.
22879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
22889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return A DTMAxisIterator, or null if the given axis isn't supported.
22899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
22909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public DTMAxisIterator getAxisIterator(final int axis)
22919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
22929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD%
22939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
22949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
22959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
22969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
22979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Get an iterator that can navigate over an XPath Axis, predicated by
22989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the extended type ID.
22999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
23009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
23019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param axis
23029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param type An extended type ID.
23039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
23049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return A DTMAxisIterator, or null if the given axis isn't supported.
23059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
23069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public DTMAxisIterator getTypedAxisIterator(final int axis, final int type)
23079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
23089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD%
23099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
23109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
23119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /** Terminate the element currently acting as an insertion point. Subsequent
23149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * insertions will occur as the last child of this element's parent.
23159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
23169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendEndElement()
23179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
23189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // pop up the stacks
23199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    if (previousSiblingWasParent)
23219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      nodes.writeEntry(previousSibling, 2, NULL);
23229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Pop parentage
23249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSibling = currentParent;
23259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    nodes.readSlot(currentParent, gotslot);
23269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    currentParent = gotslot[1] & 0xFFFF;
23279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // The element just being finished will be
23299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // the previous sibling for the next operation
23309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    previousSiblingWasParent = true;
23319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // Pop a level of namespace table
23339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // namespaceTable.removeLastElem();
23349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
23359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**  Starting a new document. Perform any resets/initialization
23379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * not already handled.
23389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
23399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendStartDocument()
23409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
23419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% reset slot 0 to indicate ChunkedIntArray reuse or wait for
23439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    //       the next initDocument().
23449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_docElement = NULL;	 // reset nodeHandle to the root of the actual dtm doc content
23459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    initDocument(0);
23469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
23479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**  All appends to this document have finished; do whatever final
23499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * cleanup is needed.
23509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * */
23519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  void appendEndDocument()
23529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
23539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    done = true;
23549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // %TBD% may need to notice the last slot number and slot count to avoid
23559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    // residual data from provious use of this DTM
23569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
23579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
23599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * For the moment all the run time properties are ignored by this
23609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * class.
23619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
23629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param property a <code>String</code> value
23639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param value an <code>Object</code> value
23649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
23659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void setProperty(String property, Object value)
23669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
23679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
23689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
23709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Source information is not handled yet, so return
23719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>null</code> here.
23729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
23739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param node an <code>int</code> value
23749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return null
23759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
23769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public SourceLocator getSourceLocatorFor(int node)
23779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
23789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return null;
23799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
23809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
23839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * A dummy routine to satisify the abstract interface. If the DTM
23849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * implememtation that extends the default base requires notification
23859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * of registration, they can override this method.
23869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
23879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   public void documentRegistration()
23889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   {
23899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   }
23909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
23919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
23929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * A dummy routine to satisify the abstract interface. If the DTM
23939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * implememtation that extends the default base requires notification
23949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * when the document is being released, they can override this method
23959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
23969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   public void documentRelease()
23979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   {
23989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   }
23999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
24009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   /**
24019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    * Migrate a DTM built with an old DTMManager to a new DTMManager.
24029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    * After the migration, the new DTMManager will treat the DTM as
24039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    * one that is built by itself.
24049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    * This is used to support DTM sharing between multiple transformations.
24059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    * @param manager the DTMManager
24069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    */
24079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   public void migrateTo(DTMManager manager)
24089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   {
24099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   }
24109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
24119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}
2412