14c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 24c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 34c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or more contributor license agreements. See the NOTICE file 44c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed with this work for additional information 54c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * regarding copyright ownership. The ASF licenses this file 64c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 74c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you may not use this file except in compliance with the License. 84c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You may obtain a copy of the License at 94c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Unless required by applicable law or agreed to in writing, software 134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * See the License for the specific language governing permissions and 164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * limitations under the License. 174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * $Id: DTMDocumentImpl.java 468653 2006-10-28 07:07:05Z minchau $ 204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpackage org.apache.xml.dtm.ref; 224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport javax.xml.transform.SourceLocator; 244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.dtm.DTM; 264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.dtm.DTMAxisIterator; 274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.dtm.DTMAxisTraverser; 284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.dtm.DTMManager; 294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.dtm.DTMWSFilter; 304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.utils.FastStringBuffer; 314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.utils.XMLString; 324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.utils.XMLStringFactory; 334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.Attributes; 354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.ContentHandler; 364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.Locator; 374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.ext.LexicalHandler; 384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/** 404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This is the implementation of the DTM document interface. It receives 414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * requests from an XML content handler similar to that of an XML DOM or SAX parser 424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to store information from the xml document in an array based 434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * dtm table structure. This informtion is used later for document navigation, 444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * query, and SAX event dispatch functions. The DTM can also be used directly as a 454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * document composition model for an application. The requests received are: 464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <ul> 474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>initiating DTM to set the doc handle</li> 484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>resetting DTM for data structure reuse</li> 494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>hinting the end of document to adjust the end of data structure pointers</li> 504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>createnodes (element, comment, text, attribute, ....)</li> 514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>hinting the end of an element to patch parent and siblings<li> 524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>setting application provided symbol name stringpool data structures</li> 534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * </ul> 544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>State: In progress!!</p> 554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% I _think_ the SAX convention is that "no namespace" is expressed 574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * as "" rather than as null (which is the DOM's convention). What should 584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTM expect? What should it do with the other? 594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>Origin: the implemention is a composite logic based on the DTM of XalanJ1 and 614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DocImpl, DocumentImpl, ElementImpl, TextImpl, etc. of XalanJ2</p> 624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpublic class DTMDocumentImpl 644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimplements DTM, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler 654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson{ 664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Number of lower bits used to represent node index. 684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson protected static final byte DOCHANDLE_SHIFT = 22; 694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Masks the lower order of node handle. 704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Same as {@link DTMConstructor.IDENT_NODE_DEFAULT} 714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson protected static final int NODEHANDLE_MASK = (1 << (DOCHANDLE_SHIFT + 1)) - 1; 724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Masks the higher order Document handle 734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Same as {@link DTMConstructor.IDENT_DOC_DEFAULT} 744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson protected static final int DOCHANDLE_MASK = -1 - NODEHANDLE_MASK; 754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int m_docHandle = NULL; // masked document handle for this dtm document 774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int m_docElement = NULL; // nodeHandle to the root of the actual dtm doc content 784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Context for parse-and-append operations 804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int currentParent = 0; // current parent - default is document root 814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int previousSibling = 0; // previous sibling - no previous sibling 824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson protected int m_currentNode = -1; // current node 834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // The tree under construction can itself be used as 854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // the element stack, so m_elemStack isn't needed. 864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //protected Stack m_elemStack = new Stack(); // element stack 874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private boolean previousSiblingWasParent = false; 894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Local cache for record-at-a-time fetch 904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int gotslot[] = new int[4]; 914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // endDocument recieved? 934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private boolean done = false; 944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson boolean m_isError = false; 954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private final boolean DEBUG = false; 974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** The document base URI. */ 994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson protected String m_documentBaseURI; 1004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** If we're building the model incrementally on demand, we need to 1024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * be able to tell the source when to send us more data. 1034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Note that if this has not been set, and you attempt to read ahead 1054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * of the current build point, we'll probably throw a null-pointer 1064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * exception. We could try to wait-and-retry instead, as a very poor 1074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * fallback, but that has all the known problems with multithreading 1084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * on multiprocessors and we Don't Want to Go There. 1094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see setIncrementalSAXSource 1114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private IncrementalSAXSource m_incrSAXSource=null; 1134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ========= DTM data structure declarations. ============== 1164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // nodes array: integer array blocks to hold the first level reference of the nodes, 1184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // each reference slot is addressed by a nodeHandle index value. 1194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Assumes indices are not larger than {@link NODEHANDLE_MASK} 1204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ({@link DOCHANDLE_SHIFT} bits). 1214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson ChunkedIntArray nodes = new ChunkedIntArray(4); 1224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // text/comment table: string buffer to hold the text string values of the document, 1244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // each of which is addressed by the absolute offset and length in the buffer 1254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private FastStringBuffer m_char = new FastStringBuffer(); 1264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Start of string currently being accumulated into m_char; 1274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // needed because the string may be appended in several chunks. 1284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private int m_char_current_start=0; 1294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% INITIALIZATION/STARTUP ISSUES 1314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // -- Should we really be creating these, or should they be 1324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // passed in from outside? Scott want to be able to share 1334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // pools across multiple documents, so setting them here is 1344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // probably not the right default. 1354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private DTMStringPool m_localNames = new DTMStringPool(); 1364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private DTMStringPool m_nsNames = new DTMStringPool(); 1374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private DTMStringPool m_prefixNames = new DTMStringPool(); 1384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% If we use the current ExpandedNameTable mapper, it 1404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // needs to be bound to the NS and local name pools. Which 1414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // means it needs to attach to them AFTER we've resolved their 1424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // startup. Or it needs to attach to this document and 1434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // retrieve them each time. Or this needs to be 1444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // an interface _implemented_ by this class... which might be simplest! 1454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private ExpandedNameTable m_expandedNames= 1464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson new ExpandedNameTable(); 1474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private XMLStringFactory m_xsf; 1494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Construct a DTM. 1534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param documentNumber the ID number assigned to this document. 1554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * It will be shifted up into the high bits and returned as part of 1564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * all node ID numbers, so those IDs indicate which document they 1574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * came from as well as a location within the document. It is the 1584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTMManager's responsibility to assign a unique number to each 1594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * document. 1604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DTMDocumentImpl(DTMManager mgr, int documentNumber, 1624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson DTMWSFilter whiteSpaceFilter, 1634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson XMLStringFactory xstringfactory){ 1644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson initDocument(documentNumber); // clear nodes and document handle 1654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_xsf = xstringfactory; 1664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 1674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Bind a IncrementalSAXSource to this DTM. If we discover we need nodes 1694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * that have not yet been built, we will ask this object to send us more 1704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * events, and it will manage interactions with its data sources. 1714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Note that we do not actually build the IncrementalSAXSource, since we don't 1734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * know what source it's reading from, what thread that source will run in, 1744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or when it will run. 1754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param source The IncrementalSAXSource that we want to recieve events from 1774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * on demand. 1784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setIncrementalSAXSource(IncrementalSAXSource source) 1804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 1814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_incrSAXSource=source; 1824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Establish SAX-stream link so we can receive the requested data 1844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson source.setContentHandler(this); 1854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson source.setLexicalHandler(this); 1864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Are the following really needed? IncrementalSAXSource doesn't yet 1884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // support them, and they're mostly no-ops here... 1894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //source.setErrorHandler(this); 1904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //source.setDTDHandler(this); 1914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //source.setDeclHandler(this); 1924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 1934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Wrapper for ChunkedIntArray.append, to automatically update the 1964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * previous sibling's "next" reference (if necessary) and periodically 1974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * wake a reader who may have encountered incomplete data and entered 1984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * a wait state. 1994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param w0 int As in ChunkedIntArray.append 2004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param w1 int As in ChunkedIntArray.append 2014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param w2 int As in ChunkedIntArray.append 2024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param w3 int As in ChunkedIntArray.append 2034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int As in ChunkedIntArray.append 2044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see ChunkedIntArray.append 2054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private final int appendNode(int w0, int w1, int w2, int w3) 2074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 2084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // A decent compiler may inline this. 2094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int slotnumber = nodes.appendSlot(w0, w1, w2, w3); 2104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (DEBUG) System.out.println(slotnumber+": "+w0+" "+w1+" "+w2+" "+w3); 2124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (previousSiblingWasParent) 2144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.writeEntry(previousSibling,2,slotnumber); 2154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSiblingWasParent = false; // Set the default; endElement overrides 2174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return slotnumber; 2194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 2204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ========= DTM Implementation Control Functions. ============== 2224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Set an implementation dependent feature. 2254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 2264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Do we really expect to set features on DTMs? 2274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param featureId A feature URL. 2294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param state true if this feature should be on, false otherwise. 2304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setFeature(String featureId, boolean state) {}; 2324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Set a reference pointer to the element name symbol table. 2354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Should this really be Public? Changing it while 2364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTM is in use would be a disaster. 2374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param poolRef DTMStringPool reference to an instance of table. 2394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setLocalNameTable(DTMStringPool poolRef) { 2414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_localNames = poolRef; 2424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 2434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get a reference pointer to the element name symbol table. 2464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return DTMStringPool reference to an instance of table. 2484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DTMStringPool getLocalNameTable() { 2504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return m_localNames; 2514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 2524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Set a reference pointer to the namespace URI symbol table. 2554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Should this really be Public? Changing it while 2564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTM is in use would be a disaster. 2574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param poolRef DTMStringPool reference to an instance of table. 2594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setNsNameTable(DTMStringPool poolRef) { 2614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_nsNames = poolRef; 2624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 2634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get a reference pointer to the namespace URI symbol table. 2664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return DTMStringPool reference to an instance of table. 2684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DTMStringPool getNsNameTable() { 2704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return m_nsNames; 2714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 2724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Set a reference pointer to the prefix name symbol table. 2754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Should this really be Public? Changing it while 2764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTM is in use would be a disaster. 2774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param poolRef DTMStringPool reference to an instance of table. 2794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setPrefixNameTable(DTMStringPool poolRef) { 2814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_prefixNames = poolRef; 2824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 2834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get a reference pointer to the prefix name symbol table. 2864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return DTMStringPool reference to an instance of table. 2884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DTMStringPool getPrefixNameTable() { 2904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return m_prefixNames; 2914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 2924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Set a reference pointer to the content-text repository 2954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param buffer FastStringBuffer reference to an instance of 2974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * buffer 2984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void setContentBuffer(FastStringBuffer buffer) { 3004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char = buffer; 3014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 3044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get a reference pointer to the content-text repository 3054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return FastStringBuffer reference to an instance of buffer 3074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 3084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson FastStringBuffer getContentBuffer() { 3094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return m_char; 3104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** getContentHandler returns "our SAX builder" -- the thing that 3134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * someone else should send SAX events to in order to extend this 3144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTM model. 3154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return null if this model doesn't respond to SAX events, 3174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * "this" if the DTM object has a built-in SAX ContentHandler, 3184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the IncrementalSAXSource if we're bound to one and should receive 3194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the SAX stream via it for incremental build purposes... 3204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 3214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public org.xml.sax.ContentHandler getContentHandler() 3224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 3234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (m_incrSAXSource instanceof IncrementalSAXSource_Filter) 3244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (ContentHandler) m_incrSAXSource; 3254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson else 3264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return this; 3274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 3304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return this DTM's lexical handler. 3314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Should this return null if constrution already done/begun? 3334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return null if this model doesn't respond to lexical SAX events, 3354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * "this" if the DTM object has a built-in SAX ContentHandler, 3364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the IncrementalSAXSource if we're bound to one and should receive 3374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the SAX stream via it for incremental build purposes... 3384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 3394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public LexicalHandler getLexicalHandler() 3404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 3414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (m_incrSAXSource instanceof IncrementalSAXSource_Filter) 3434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (LexicalHandler) m_incrSAXSource; 3444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson else 3454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return this; 3464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 3494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return this DTM's EntityResolver. 3504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return null if this model doesn't respond to SAX entity ref events. 3524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 3534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public org.xml.sax.EntityResolver getEntityResolver() 3544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 3554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 3574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 3604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return this DTM's DTDHandler. 3614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return null if this model doesn't respond to SAX dtd events. 3634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 3644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public org.xml.sax.DTDHandler getDTDHandler() 3654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 3664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 3684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 3714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return this DTM's ErrorHandler. 3724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return null if this model doesn't respond to SAX error events. 3744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 3754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public org.xml.sax.ErrorHandler getErrorHandler() 3764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 3774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 3794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 3824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return this DTM's DeclHandler. 3834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 3844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return null if this model doesn't respond to SAX Decl events. 3854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 3864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public org.xml.sax.ext.DeclHandler getDeclHandler() 3874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 3884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 3904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 3914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 3924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** @return true iff we're building this model incrementally (eg 3934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * we're partnered with a IncrementalSAXSource) and thus require that the 3944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * transformation and the parse run simultaneously. Guidance to the 3954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTMManager. 3964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 3974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean needsTwoThreads() 3984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 3994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null!=m_incrSAXSource; 4004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 4024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //================================================================ 4034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ========= SAX2 ContentHandler methods ========= 4044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Accept SAX events, use them to build/extend the DTM tree. 4054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Replaces the deprecated DocumentHandler interface. 4064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 4074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void characters(char[] ch, int start, int length) 4084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Actually creating the text node is handled by 4114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // processAccumulatedText(); here we just accumulate the 4124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // characters into the buffer. 4134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char.append(ch,start,length); 4144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 4164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Flush string accumulation into a text node 4174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private void processAccumulatedText() 4184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int len=m_char.length(); 4204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(len!=m_char_current_start) 4214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // The FastStringBuffer has been previously agreed upon 4234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendTextChild(m_char_current_start,len-m_char_current_start); 4244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char_current_start=len; 4254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void endDocument() 4284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // May need to tell the low-level builder code to pop up a level. 4314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // There _should't_ be any significant pending text at this point. 4324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendEndDocument(); 4334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void endElement(java.lang.String namespaceURI, java.lang.String localName, 4354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson java.lang.String qName) 4364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson processAccumulatedText(); 4394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No args but we do need to tell the low-level builder code to 4404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // pop up a level. 4414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendEndElement(); 4424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void endPrefixMapping(java.lang.String prefix) 4444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op 4474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void ignorableWhitespace(char[] ch, int start, int length) 4494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% I believe ignorable text isn't part of the DTM model...? 4524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void processingInstruction(java.lang.String target, java.lang.String data) 4544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson processAccumulatedText(); 4574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% Which pools do target and data go into? 4584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setDocumentLocator(Locator locator) 4604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op for DTM 4624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void skippedEntity(java.lang.String name) 4644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson processAccumulatedText(); 4674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //%TBD% 4684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startDocument() 4704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendStartDocument(); 4734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 4744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startElement(java.lang.String namespaceURI, java.lang.String localName, 4754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson java.lang.String qName, Attributes atts) 4764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 4774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson processAccumulatedText(); 4794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 4804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% Split prefix off qname 4814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String prefix=null; 4824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int colon=qName.indexOf(':'); 4834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(colon>0) 4844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson prefix=qName.substring(0,colon); 4854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 4864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% Where do we pool expandedName, or is it just the union, or... 4874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /**/System.out.println("Prefix="+prefix+" index="+m_prefixNames.stringToIndex(prefix)); 4884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendStartElement(m_nsNames.stringToIndex(namespaceURI), 4894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_localNames.stringToIndex(localName), 4904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_prefixNames.stringToIndex(prefix)); /////// %TBD% 4914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 4924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% I'm assuming that DTM will require resequencing of 4934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // NS decls before other attrs, hence two passes are taken. 4944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% Is there an easier way to test for NSDecl? 4954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int nAtts=(atts==null) ? 0 : atts.getLength(); 4964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% Countdown is more efficient if nobody cares about sequence. 4974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson for(int i=nAtts-1;i>=0;--i) 4984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 4994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson qName=atts.getQName(i); 5004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(qName.startsWith("xmlns:") || "xmlns".equals(qName)) 5014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson prefix=null; 5034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson colon=qName.indexOf(':'); 5044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(colon>0) 5054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson prefix=qName.substring(0,colon); 5074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson else 5094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %REVEIW% Null or ""? 5114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson prefix=null; // Default prefix 5124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendNSDeclaration( 5164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_prefixNames.stringToIndex(prefix), 5174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_nsNames.stringToIndex(atts.getValue(i)), 5184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson atts.getType(i).equalsIgnoreCase("ID")); 5194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson for(int i=nAtts-1;i>=0;--i) 5234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson qName=atts.getQName(i); 5254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(!(qName.startsWith("xmlns:") || "xmlns".equals(qName))) 5264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% I hate having to extract the prefix into a new 5284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // string when we may never use it. Consider pooling whole 5294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // qNames, which are already strings? 5304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson prefix=null; 5314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson colon=qName.indexOf(':'); 5324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(colon>0) 5334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson prefix=qName.substring(0,colon); 5354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson localName=qName.substring(colon+1); 5364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson else 5384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson prefix=""; // Default prefix 5404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson localName=qName; 5414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char.append(atts.getValue(i)); // Single-string value 5454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int contentEnd=m_char.length(); 5464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(!("xmlns".equals(prefix) || "xmlns".equals(qName))) 5484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendAttribute(m_nsNames.stringToIndex(atts.getURI(i)), 5494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_localNames.stringToIndex(localName), 5504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_prefixNames.stringToIndex(prefix), 5514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson atts.getType(i).equalsIgnoreCase("ID"), 5524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char_current_start, contentEnd-m_char_current_start); 5534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char_current_start=contentEnd; 5544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) 5584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 5594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op in DTM, handled during element/attr processing? 5614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // 5644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // LexicalHandler support. Not all SAX2 parsers support these events 5654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // but we may want to pass them through when they exist... 5664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // 5674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void comment(char[] ch, int start, int length) 5684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 5694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson processAccumulatedText(); 5714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 5724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char.append(ch,start,length); // Single-string value 5734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendComment(m_char_current_start,length); 5744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_char_current_start+=length; 5754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void endCDATA() 5774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 5784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op in DTM 5804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void endDTD() 5824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 5834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op in DTM 5854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void endEntity(java.lang.String name) 5874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 5884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op in DTM 5904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startCDATA() 5924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 5934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 5944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op in DTM 5954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 5964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startDTD(java.lang.String name, java.lang.String publicId, 5974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson java.lang.String systemId) 5984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 5994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 6004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op in DTM 6014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 6024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void startEntity(java.lang.String name) 6034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException 6044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 6054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No-op in DTM 6064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 6074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //================================================================ 6104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ========= Document Handler Functions ========= 6114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %REVIEW% jjk -- DocumentHandler is SAX Level 1, and deprecated.... 6124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // and this wasn't a fully compliant or declared implementation of that API 6134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // in any case. Phase out in favor of SAX2 ContentHandler/LexicalHandler 6144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 6164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Reset a dtm document to its initial (empty) state. 6174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 6184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The DTMManager will invoke this method when the dtm is created. 6194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 6204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param documentNumber the handle for the DTM document. 6214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 6224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson final void initDocument(int documentNumber) 6234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 6244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // save masked DTM document handle 6254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_docHandle = documentNumber<<DOCHANDLE_SHIFT; 6264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Initialize the doc -- no parent, no next-sib 6284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.writeSlot(0,DOCUMENT_NODE,-1,-1,0); 6294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // wait for the first startElement to create the doc root node 6304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson done = false; 6314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 6324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 6344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Receive hint of the end of a document. 6354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 6364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The content handler will invoke this method only once, and it will 6374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * be the last method invoked during the parse. The handler shall not 6384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * not invoke this method until it has either abandoned parsing 6394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * (because of an unrecoverable error) or reached the end of 6404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * input.</p> 6414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 6424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public void documentEnd() 6434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 6444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// done = true; 6454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // %TBD% may need to notice the last slot number and slot count to avoid 6464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // residual data from provious use of this DTM 6474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 6484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 6504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Receive notification of the beginning of a document. 6514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 6524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The SAX parser will invoke this method only once, before any 6534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * other methods in this interface.</p> 6544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 6554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public void reset() 6564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 6574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // %TBD% reset slot 0 to indicate ChunkedIntArray reuse or wait for 6594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // the next initDocument(). 6604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// m_docElement = NULL; // reset nodeHandle to the root of the actual dtm doc content 6614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// initDocument(0); 6624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 6634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 6654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Factory method; creates an Element node in this document. 6664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 6674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * The node created will be chained according to its natural order of request 6684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * received. %TBD% It can be rechained later via the optional DTM writable interface. 6694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 6704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The XML content handler will invoke endElement() method after all 6714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * of the element's content are processed in order to give DTM the indication 6724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * to prepare and patch up parent and sibling node pointers.</p> 6734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 6744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The following interface for createElement will use an index value corresponds 6754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * to the symbol entry in the DTMDStringPool based symbol tables.</p> 6764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 6774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param nsIndex The namespace of the node 6784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param nameIndex The element name. 6794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @see #endElement 6804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @see org.xml.sax.Attributes 6814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @return nodeHandle int of the element created 6824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 6834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createElement(int nsIndex, int nameIndex, Attributes atts) 6844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 6854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // do document root node creation here on the first element, create nodes for 6864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // this element and its attributes, store the element, namespace, and attritute 6874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // name indexes to the nodes array, keep track of the current node and parent 6884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // element used 6894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 6904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W0 High: Namespace Low: Node Type 6914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w0 = (nsIndex << 16) | ELEMENT_NODE; 6924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W1: Parent 6934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w1 = currentParent; 6944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W2: Next (initialized as 0) 6954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w2 = 0; 6964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W3: Tagname 6974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w3 = nameIndex; 6984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// //int ourslot = nodes.appendSlot(w0, w1, w2, w3); 6994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int ourslot = appendNode(w0, w1, w2, w3); 7004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// currentParent = ourslot; 7014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// previousSibling = 0; 7024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// setAttributes(atts); 7034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 7044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // set the root element pointer when creating the first element node 7054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// if (m_docElement == NULL) 7064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// m_docElement = ourslot; 7074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return (m_docHandle | ourslot); 7084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 7094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 7104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // Factory method to create an Element node not associated with a given name space 7114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // using String value parameters passed in from a content handler or application 7124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 7134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Factory method; creates an Element node not associated with a given name space in this document. 7144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * The node created will be chained according to its natural order of request 7164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * received. %TBD% It can be rechained later via the optional DTM writable interface. 7174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The XML content handler or application will invoke endElement() method after all 7194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * of the element's content are processed in order to give DTM the indication 7204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * to prepare and patch up parent and sibling node pointers.</p> 7214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The following parameters for createElement contains raw string values for name 7234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * symbols used in an Element node.</p> 7244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param name String the element name, including the prefix if any. 7264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param atts The attributes attached to the element, if any. 7274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @see #endElement 7284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @see org.xml.sax.Attributes 7294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 7304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createElement(String name, Attributes atts) 7314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 7324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // This method wraps around the index valued interface of the createElement interface. 7334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // The raw string values are stored into the current DTM name symbol tables. The method 7344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // method will then use the index values returned to invoke the other createElement() 7354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // onverted to index values modified to match a 7364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // method. 7374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int nsIndex = NULL; 7384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int nameIndex = m_localNames.stringToIndex(name); 7394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // note - there should be no prefix separator in the name because it is not associated 7404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // with a name space 7414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 7424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return createElement(nsIndex, nameIndex, atts); 7434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 7444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 7454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // Factory method to create an Element node associated with a given name space 7464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // using String value parameters passed in from a content handler or application 7474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 7484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Factory method; creates an Element node associated with a given name space in this document. 7494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * The node created will be chained according to its natural order of request 7514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * received. %TBD% It can be rechained later via the optional DTM writable interface. 7524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The XML content handler or application will invoke endElement() method after all 7544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * of the element's content are processed in order to give DTM the indication 7554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * to prepare and patch up parent and sibling node pointers.</p> 7564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The following parameters for createElementNS contains raw string values for name 7584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * symbols used in an Element node.</p> 7594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param ns String the namespace of the node 7614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param name String the element name, including the prefix if any. 7624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param atts The attributes attached to the element, if any. 7634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @see #endElement 7644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @see org.xml.sax.Attributes 7654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 7664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createElementNS(String ns, String name, Attributes atts) 7674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 7684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // This method wraps around the index valued interface of the createElement interface. 7694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // The raw string values are stored into the current DTM name symbol tables. The method 7704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // method will then use the index values returned to invoke the other createElement() 7714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // onverted to index values modified to match a 7724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // method. 7734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int nsIndex = m_nsNames.stringToIndex(ns); 7744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int nameIndex = m_localNames.stringToIndex(name); 7754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // The prefixIndex is not needed by the indexed interface of the createElement method 7764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int prefixSep = name.indexOf(":"); 7774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int prefixIndex = m_prefixNames.stringToIndex(name.substring(0, prefixSep)); 7784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return createElement(nsIndex, nameIndex, atts); 7794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 7804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 7814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 7824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Receive an indication for the end of an element. 7834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>The XML content handler will invoke this method at the end of every 7854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * element in the XML document to give hint its time to pop up the current 7864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * element and parent and patch up parent and sibling pointers if necessary 7874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * <p>%tbd% The following interface may need to be modified to match a 7894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * coordinated access to the DTMDStringPool based symbol tables.</p> 7904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 7914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param ns the namespace of the element 7924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param name The element name 7934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 7944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public void endElement(String ns, String name) 7954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 7964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // pop up the stacks 7974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 7984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // 7994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// if (previousSiblingWasParent) 8004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// nodes.writeEntry(previousSibling, 2, NULL); 8014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // Pop parentage 8034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// previousSibling = currentParent; 8044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// nodes.readSlot(currentParent, gotslot); 8054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// currentParent = gotslot[1] & 0xFFFF; 8064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // The element just being finished will be 8084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // the previous sibling for the next operation 8094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// previousSiblingWasParent = true; 8104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // Pop a level of namespace table 8124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // namespaceTable.removeLastElem(); 8134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 8144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 8164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Creates attributes for the current node. 8174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 8184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param atts Attributes to be created. 8194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 8204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// void setAttributes(Attributes atts) { 8214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int atLength = (null == atts) ? 0 : atts.getLength(); 8224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// for (int i=0; i < atLength; i++) { 8234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// String qname = atts.getQName(i); 8244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// createAttribute(atts.getQName(i), atts.getValue(i)); 8254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 8264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 8274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 8294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Appends an attribute to the document. 8304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param qname Qualified Name of the attribute 8314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param value Value of the attribute 8324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @return Handle of node 8334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 8344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createAttribute(String qname, String value) { 8354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int colonpos = qname.indexOf(":"); 8364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// String attName = qname.substring(colonpos+1); 8374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w0 = 0; 8384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// if (colonpos > 0) { 8394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// String prefix = qname.substring(0, colonpos); 8404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// if (prefix.equals("xml")) { 8414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// //w0 = ATTRIBUTE_NODE | 8424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // (org.apache.xalan.templates.Constants.S_XMLNAMESPACEURI << 16); 8434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } else { 8444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// //w0 = ATTRIBUTE_NODE | 8454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 8464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } else { 8474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// w0 = ATTRIBUTE_NODE; 8484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 8494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W1: Parent 8504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w1 = currentParent; 8514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W2: Next (not yet resolved) 8524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w2 = 0; 8534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W3: Tag name 8544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w3 = m_localNames.stringToIndex(attName); 8554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // Add node 8564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int ourslot = appendNode(w0, w1, w2, w3); 8574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// previousSibling = ourslot; // Should attributes be previous siblings 8584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W0: Node Type 8604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// w0 = TEXT_NODE; 8614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W1: Parent 8624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// w1 = ourslot; 8634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W2: Start Position within buffer 8644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// w2 = m_char.length(); 8654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// m_char.append(value); 8664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W3: Length 8674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// w3 = m_char.length() - w2; 8684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// appendNode(w0, w1, w2, w3); 8694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// charStringStart=m_char.length(); 8704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// charStringLength = 0; 8714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// //previousSibling = ourslot; 8724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // Attrs are Parents 8734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// previousSiblingWasParent = true; 8744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return (m_docHandle | ourslot); 8754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 8764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 8784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Factory method; creates a Text node in this document. 8794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 8804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * The node created will be chained according to its natural order of request 8814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * received. %TBD% It can be rechained later via the optional DTM writable interface. 8824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 8834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param text String The characters text string from the XML document. 8844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @return int DTM node-number of the text node created 8854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 8864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createTextNode(String text) 8874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// throws DTMException 8884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 8894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // wraps around the index value based createTextNode method 8904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return createTextNode(text.toCharArray(), 0, text.length()); 8914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 8924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 8934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 8944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Factory method; creates a Text node in this document. 8954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 8964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * The node created will be chained according to its natural order of request 8974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * received. %TBD% It can be rechained later via the optional DTM writable interface. 8984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 8994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * %REVIEW% for text normalization issues, unless we are willing to 9004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * insist that all adjacent text must be merged before this method 9014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * is called. 9024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 9034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param ch The characters from the XML document. 9044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param start The start position in the array. 9054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param length The number of characters to read from the array. 9064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 9074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createTextNode(char ch[], int start, int length) 9084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// throws DTMException 9094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 9104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// m_char.append(ch, start, length); // store the chunk to the text/comment string table 9114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // create a Text Node 9134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // %TBD% may be possible to combine with appendNode()to replace the next chunk of code 9144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w0 = TEXT_NODE; 9154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W1: Parent 9164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w1 = currentParent; 9174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W2: Start position within m_char 9184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w2 = charStringStart; 9194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W3: Length of the full string 9204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w3 = length; 9214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int ourslot = appendNode(w0, w1, w2, w3); 9224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// previousSibling = ourslot; 9234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// charStringStart=m_char.length(); 9254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// charStringLength = 0; 9264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return (m_docHandle | ourslot); 9274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 9284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 9304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Factory method; creates a Comment node in this document. 9314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 9324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * The node created will be chained according to its natural order of request 9334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * received. %TBD% It can be rechained later via the optional DTM writable interface. 9344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 9354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param text String The characters text string from the XML document. 9364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @return int DTM node-number of the text node created 9374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 9384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createComment(String text) 9394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// throws DTMException 9404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 9414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // wraps around the index value based createTextNode method 9424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return createComment(text.toCharArray(), 0, text.length()); 9434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 9444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// /** 9464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * Factory method; creates a Comment node in this document. 9474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 9484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * The node created will be chained according to its natural order of request 9494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * received. %TBD% It can be rechained later via the optional DTM writable interface. 9504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * 9514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param ch An array holding the characters in the comment. 9524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param start The starting position in the array. 9534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @param length The number of characters to use from the array. 9544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// * @see DTMException 9554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// */ 9564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// public int createComment(char ch[], int start, int length) 9574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// throws DTMException 9584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// { 9594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// m_char.append(ch, start, length); // store the comment string to the text/comment string table 9604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // create a Comment Node 9624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // %TBD% may be possible to combine with appendNode()to replace the next chunk of code 9634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w0 = COMMENT_NODE; 9644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W1: Parent 9654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w1 = currentParent; 9664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W2: Start position within m_char 9674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w2 = charStringStart; 9684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // W3: Length of the full string 9694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int w3 = length; 9704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int ourslot = appendNode(w0, w1, w2, w3); 9714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// previousSibling = ourslot; 9724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// charStringStart=m_char.length(); 9744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// charStringLength = 0; 9754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// return (m_docHandle | ourslot); 9764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// } 9774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // Counters to keep track of the current text string being accumulated with respect 9794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // to the text/comment string table: charStringStart should point to the starting 9804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // offset of the string in the table and charStringLength the acccumulated length when 9814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // appendAccumulatedText starts, and reset to the end of the table and 0 at the end 9824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// // of appendAccumulatedText for the next set of characters receives 9834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson// int charStringStart=0,charStringLength=0; 9844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ========= Document Navigation Functions ========= 9864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 9874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Given a node handle, test if it has child nodes. 9884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> %REVIEW% This is obviously useful at the DOM layer, where it 9894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * would permit testing this without having to create a proxy 9904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * node. It's less useful in the DTM API, where 9914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (dtm.getFirstChild(nodeHandle)!=DTM.NULL) is just as fast and 9924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * almost as self-evident. But it's a convenience, and eases porting 9934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * of DOM code to DTM. </p> 9944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 9954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the node. 9964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int true if the given node has child nodes. 9974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 9984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean hasChildNodes(int nodeHandle) { 9994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return(getFirstChild(nodeHandle) != NULL); 10004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 10014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 10034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, get the handle of the node's first child. 10044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If not yet resolved, waits for more nodes to be added to the document and 10054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * tries again. 10064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 10074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the node. 10084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int DTM node-number of first child, or DTM.NULL to indicate none exists. 10094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 10104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getFirstChild(int nodeHandle) { 10114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ###shs worry about tracing/debug later 10134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 10144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Read node into variable 10154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 10164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // type is the last half of first slot 10184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (gotslot[0] & 0xFFFF); 10194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Check to see if Element or Document node 10214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if ((type == ELEMENT_NODE) || (type == DOCUMENT_NODE) || 10224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson (type == ENTITY_REFERENCE_NODE)) { 10234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // In case when Document root is given 10254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // if (nodeHandle == 0) nodeHandle = 1; 10264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% Probably was a mistake. 10274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // If someone explicitly asks for first child 10284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // of Document, I would expect them to want 10294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // that and only that. 10304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int kid = nodeHandle + 1; 10324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(kid, gotslot); 10334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson while (ATTRIBUTE_NODE == (gotslot[0] & 0xFFFF)) { 10344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // points to next sibling 10354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson kid = gotslot[2]; 10364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Return NULL if node has only attributes 10374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (kid == NULL) return NULL; 10384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(kid, gotslot); 10394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 10404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // If parent slot matches given parent, return kid 10414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (gotslot[1] == nodeHandle) 10424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 10434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int firstChild = kid | m_docHandle; 10444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return firstChild; 10464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 10474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 10484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // No child found 10494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 10514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 10524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 10544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, advance to its last child. 10554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If not yet resolved, waits for more nodes to be added to the document and 10564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * tries again. 10574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 10584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the node. 10594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node-number of last child, 10604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 10614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 10624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getLastChild(int nodeHandle) { 10634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ###shs put trace/debug later 10644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 10654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // do not need to test node type since getFirstChild does that 10664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int lastChild = NULL; 10674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson for (int nextkid = getFirstChild(nodeHandle); nextkid != NULL; 10684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nextkid = getNextSibling(nextkid)) { 10694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson lastChild = nextkid; 10704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 10714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return lastChild | m_docHandle; 10724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 10734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 10744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 10754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Retrieves an attribute node by by qualified name and namespace URI. 10764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 10774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the node upon which to look up this attribute. 10784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param namespaceURI The namespace URI of the attribute to 10794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * retrieve, or null. 10804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param name The local name of the attribute to 10814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * retrieve. 10824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return The attribute node handle with the specified name ( 10834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such 10844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * attribute. 10854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 10864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getAttributeNode(int nodeHandle, String namespaceURI, String name) { 10874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int nsIndex = m_nsNames.stringToIndex(namespaceURI), 10884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nameIndex = m_localNames.stringToIndex(name); 10894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 10904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 10914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (gotslot[0] & 0xFFFF); 10924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // If nodeHandle points to element next slot would be first attribute 10934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (type == ELEMENT_NODE) 10944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle++; 10954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Iterate through Attribute Nodes 10964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson while (type == ATTRIBUTE_NODE) { 10974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if ((nsIndex == (gotslot[0] << 16)) && (gotslot[3] == nameIndex)) 10984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return nodeHandle | m_docHandle; 10994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Goto next sibling 11004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle = gotslot[2]; 11014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 11024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 11034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 11044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 11054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 11074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, get the index of the node's first attribute. 11084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 11094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the Element node. 11104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return Handle of first attribute, or DTM.NULL to indicate none exists. 11114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 11124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getFirstAttribute(int nodeHandle) { 11134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 11144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %REVIEW% jjk: Just a quick observation: If you're going to 11164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // call readEntry repeatedly on the same node, it may be 11174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // more efficiently to do a readSlot to get the data locally, 11184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // reducing the addressing and call-and-return overhead. 11194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Should we check if handle is element (do we want sanity checks?) 11214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (ELEMENT_NODE != (nodes.readEntry(nodeHandle, 0) & 0xFFFF)) 11224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 11234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // First Attribute (if any) should be at next position in table 11244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle++; 11254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return(ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF)) ? 11264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle | m_docHandle : NULL; 11274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 11284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 11304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, get the index of the node's first child. 11314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If not yet resolved, waits for more nodes to be added to the document and 11324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * tries again 11334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 11344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle handle to node, which should probably be an element 11354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * node, but need not be. 11364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 11374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param inScope true if all namespaces in scope should be returned, 11384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * false if only the namespace declarations should be 11394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * returned. 11404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return handle of first namespace, or DTM.NULL to indicate none exists. 11414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 11424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getFirstNamespaceNode(int nodeHandle, boolean inScope) { 11434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 11454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 11464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 11484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, advance to its next sibling. 11494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 11504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %TBD% This currently uses the DTM-internal definition of 11514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * sibling; eg, the last attr's next sib is the first 11524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * child. In the old DTM, the DOM proxy layer provided the 11534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * additional logic for the public view. If we're rewriting 11544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * for XPath emulation, that test must be done here. 11554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 11564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %TBD% CODE INTERACTION WITH INCREMENTAL PARSE - If not yet 11574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * resolved, should wait for more nodes to be added to the document 11584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * and tries again. 11594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 11604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the node. 11614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node-number of next sibling, 11624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 11634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 11644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getNextSibling(int nodeHandle) { 11654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 11664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Document root has no next sibling 11674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nodeHandle == 0) 11684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 11694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (nodes.readEntry(nodeHandle, 0) & 0xFFFF); 11714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if ((type == ELEMENT_NODE) || (type == ATTRIBUTE_NODE) || 11724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson (type == ENTITY_REFERENCE_NODE)) { 11734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int nextSib = nodes.readEntry(nodeHandle, 2); 11744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nextSib == NULL) 11754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 11764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nextSib != 0) 11774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (m_docHandle | nextSib); 11784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ###shs should cycle/wait if nextSib is 0? Working on threading next 11794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 11804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Next Sibling is in the next position if it shares the same parent 11814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int thisParent = nodes.readEntry(nodeHandle, 1); 11824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nodes.readEntry(++nodeHandle, 1) == thisParent) 11844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (m_docHandle | nodeHandle); 11854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 11874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 11884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 11894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 11904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, find its preceeding sibling. 11914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WARNING: DTM is asymmetric; this operation is resolved by search, and is 11924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * relatively expensive. 11934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 11944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 11954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node-number of the previous sib, 11964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 11974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 11984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getPreviousSibling(int nodeHandle) { 11994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 12004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Document root has no previous sibling 12014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nodeHandle == 0) 12024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 12034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 12044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int parent = nodes.readEntry(nodeHandle, 1); 12054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int kid = NULL; 12064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson for (int nextkid = getFirstChild(parent); nextkid != nodeHandle; 12074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nextkid = getNextSibling(nextkid)) { 12084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson kid = nextkid; 12094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return kid | m_docHandle; 12114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 12134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 12144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, advance to the next attribute. If an 12154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * element, we advance to its first attribute; if an attr, we advance to 12164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the next attr on the same node. 12174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 12184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the node. 12194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int DTM node-number of the resolved attr, 12204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 12214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 12224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getNextAttribute(int nodeHandle) { 12234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 12244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 12254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 12264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //%REVIEW% Why are we using short here? There's no storage 12274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //reduction for an automatic variable, especially one used 12284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //so briefly, and it typically costs more cycles to process 12294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //than an int would. 12304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (gotslot[0] & 0xFFFF); 12314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 12324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (type == ELEMENT_NODE) { 12334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return getFirstAttribute(nodeHandle); 12344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } else if (type == ATTRIBUTE_NODE) { 12354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (gotslot[2] != NULL) 12364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (m_docHandle | gotslot[2]); 12374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 12394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 12414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 12424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a namespace handle, advance to the next namespace. 12434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 12444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %TBD% THIS METHOD DOES NOT MATCH THE CURRENT SIGNATURE IN 12454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * THE DTM INTERFACE. FIX IT, OR JUSTIFY CHANGING THE DTM 12464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * API. 12474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 12484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param namespaceHandle handle to node which must be of type NAMESPACE_NODE. 12494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return handle of next namespace, or DTM.NULL to indicate none exists. 12504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 12514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getNextNamespaceNode(int baseHandle,int namespaceHandle, boolean inScope) { 12524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ###shs need to work on namespace 12534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 12544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 12564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 12574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, advance to its next descendant. 12584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If not yet resolved, waits for more nodes to be added to the document and 12594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * tries again. 12604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 12614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param subtreeRootHandle 12624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle int Handle of the node. 12634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return handle of next descendant, 12644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 12654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 12664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getNextDescendant(int subtreeRootHandle, int nodeHandle) { 12674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson subtreeRootHandle &= NODEHANDLE_MASK; 12684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 12694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Document root [Document Node? -- jjk] - no next-sib 12704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nodeHandle == 0) 12714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 12724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson while (!m_isError) { 12734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Document done and node out of bounds 12744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (done && (nodeHandle > nodes.slotsUsed())) 12754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson break; 12764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nodeHandle > subtreeRootHandle) { 12774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle+1, gotslot); 12784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (gotslot[2] != 0) { 12794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (gotslot[0] & 0xFFFF); 12804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (type == ATTRIBUTE_NODE) { 12814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle +=2; 12824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } else { 12834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int nextParentPos = gotslot[1]; 12844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (nextParentPos >= subtreeRootHandle) 12854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (m_docHandle | (nodeHandle+1)); 12864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson else 12874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson break; 12884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } else if (!done) { 12904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Add wait logic here 12914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } else 12924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson break; 12934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } else { 12944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle++; 12954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 12974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Probably should throw error here like original instead of returning 12984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 12994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 13024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, advance to the next node on the following axis. 13034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 13044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param axisContextHandle the start of the axis that is being traversed. 13054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle 13064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return handle of next sibling, 13074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 13084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 13094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getNextFollowing(int axisContextHandle, int nodeHandle) { 13104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //###shs still working on 13114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 13124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 13154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, advance to the next node on the preceding axis. 13164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 13174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param axisContextHandle the start of the axis that is being traversed. 13184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 13194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node-number of preceding sibling, 13204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 13214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 13224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getNextPreceding(int axisContextHandle, int nodeHandle) { 13234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ###shs copied from Xalan 1, what is this suppose to do? 13244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle &= NODEHANDLE_MASK; 13254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson while (nodeHandle > 1) { 13264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle--; 13274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (ATTRIBUTE_NODE == (nodes.readEntry(nodeHandle, 0) & 0xFFFF)) 13284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson continue; 13294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // if nodeHandle is _not_ an ancestor of 13314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // axisContextHandle, specialFind will return it. 13324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // If it _is_ an ancestor, specialFind will return -1 13334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %REVIEW% unconditional return defeats the 13354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // purpose of the while loop -- does this 13364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // logic make any sense? 13374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (m_docHandle | nodes.specialFind(axisContextHandle, nodeHandle)); 13394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 13414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 13444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, find its parent node. 13454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 13464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 13474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node-number of parent, 13484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or DTM.NULL to indicate none exists. 13494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 13504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getParent(int nodeHandle) { 13514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Should check to see within range? 13524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Document Root should not have to be handled differently 13544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (m_docHandle | nodes.readEntry(nodeHandle, 1)); 13554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 13584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Returns the root element of the document. 13594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return nodeHandle to the Document Root. 13604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 13614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getDocumentRoot() { 13624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (m_docHandle | m_docElement); 13634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 13664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, find the owning document node. 13674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 13684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node handle of document, which should always be valid. 13694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 13704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getDocument() { 13714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return m_docHandle; 13724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 13754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, find the owning document node. This has the exact 13764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * same semantics as the DOM Document method of the same name, in that if 13774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the nodeHandle is a document node, it will return NULL. 13784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 13794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM 13804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * binding layer. Included here as a convenience function and to 13814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * aid porting of DOM code to DTM.</p> 13824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 13834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 13844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node handle of owning document, or NULL if the nodeHandle is 13854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * a document. 13864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 13874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getOwnerDocument(int nodeHandle) { 13884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Assumption that Document Node is always in 0 slot 13894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if ((nodeHandle & NODEHANDLE_MASK) == 0) 13904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 13914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (nodeHandle & DOCHANDLE_MASK); 13924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 13934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 13944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 13954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, find the owning document node. This has the DTM 13964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * semantics; a Document node is its own owner. 13974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 13984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>%REVIEW% Since this is DOM-specific, it may belong at the DOM 13994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * binding layer. Included here as a convenience function and to 14004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * aid porting of DOM code to DTM.</p> 14014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 14034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node handle of owning document, or NULL if the nodeHandle is 14044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * a document. 14054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 14064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getDocumentRoot(int nodeHandle) { 14074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Assumption that Document Node is always in 0 slot 14084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if ((nodeHandle & NODEHANDLE_MASK) == 0) 14094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return NULL; 14104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return (nodeHandle & DOCHANDLE_MASK); 14114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 14124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 14134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 14144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get the string-value of a node as a String object 14154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (see http://www.w3.org/TR/xpath#data-model 14164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * for the definition of a node's string-value). 14174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node ID. 14194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return A string object that represents the string-value of the given node. 14214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 14224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public XMLString getStringValue(int nodeHandle) { 14234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ###zaj - researching 14244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 14254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int nodetype=gotslot[0] & 0xFF; 14264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String value=null; 14274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 14284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson switch (nodetype) { 14294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case TEXT_NODE: 14304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case COMMENT_NODE: 14314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case CDATA_SECTION_NODE: 14324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson value= m_char.getString(gotslot[2], gotslot[3]); 14334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson break; 14344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case PROCESSING_INSTRUCTION_NODE: 14354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case ATTRIBUTE_NODE: 14364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case ELEMENT_NODE: 14374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case ENTITY_REFERENCE_NODE: 14384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson default: 14394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson break; 14404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 14414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return m_xsf.newstr( value ); 14424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 14434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 14444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 14454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 14464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get number of character array chunks in 14474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the string-value of a node. 14484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (see http://www.w3.org/TR/xpath#data-model 14494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * for the definition of a node's string-value). 14504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Note that a single text node may have multiple text chunks. 14514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * EXPLANATION: This method is an artifact of the fact that the 14534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * underlying m_chars object may not store characters in a 14544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * single contiguous array -- for example,the current 14554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * FastStringBuffer may split a single node's text across 14564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * multiple allocation units. This call tells us how many 14574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * separate accesses will be required to retrieve the entire 14584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * content. PLEASE NOTE that this may not be the same as the 14594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * number of SAX characters() events that caused the text node 14604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to be built in the first place, since m_chars buffering may 14614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * be on different boundaries than the parser's buffers. 14624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node ID. 14644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return number of character array chunks in 14664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the string-value of a node. 14674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 14684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //###zaj - tbd 14694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getStringValueChunkCount(int nodeHandle) 14704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 14714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //###zaj return value 14724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return 0; 14734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 14744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 14754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 14764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get a character array chunk in the string-value of a node. 14774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (see http://www.w3.org/TR/xpath#data-model 14784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * for the definition of a node's string-value). 14794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Note that a single text node may have multiple text chunks. 14804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * EXPLANATION: This method is an artifact of the fact that 14824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the underlying m_chars object may not store characters in a 14834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * single contiguous array -- for example,the current 14844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * FastStringBuffer may split a single node's text across 14854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * multiple allocation units. This call retrieves a single 14864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * contiguous portion of the text -- as much as m-chars was 14874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * able to store in a single allocation unit. PLEASE NOTE 14884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * that this may not be the same granularityas the SAX 14894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * characters() events that caused the text node to be built 14904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * in the first place, since m_chars buffering may be on 14914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * different boundaries than the parser's buffers. 14924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node ID. 14944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param chunkIndex Which chunk to get. 14954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param startAndLen An array of 2 where the start position and length of 14964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the chunk will be returned. 14974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 14984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return The character array reference where the chunk occurs. */ 14994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //###zaj - tbd 15004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public char[] getStringValueChunk(int nodeHandle, int chunkIndex, 15014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int[] startAndLen) {return new char[0];} 15024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 15044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return an ID that represents the node's expanded name. 15054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 15064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The handle to the node in question. 15074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 15084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the expanded-name id of the node. 15094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 15104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getExpandedTypeID(int nodeHandle) { 15114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 15124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String qName = m_localNames.indexToString(gotslot[3]); 15134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Remove prefix from qName 15144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% jjk This is assuming the elementName is the qName. 15154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int colonpos = qName.indexOf(":"); 15164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String localName = qName.substring(colonpos+1); 15174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Get NS 15184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String namespace = m_nsNames.indexToString(gotslot[0] << 16); 15194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Create expanded name 15204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String expandedName = namespace + ":" + localName; 15214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int expandedNameID = m_nsNames.stringToIndex(expandedName); 15224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return expandedNameID; 15244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 15254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 15284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given an expanded name, return an ID. If the expanded-name does not 15294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * exist in the internal tables, the entry will be created, and the ID will 15304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * be returned. Any additional nodes that are created that have this 15314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * expanded name will use this ID. 15324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 15334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the expanded-name id of the node. 15344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 15354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getExpandedTypeID(String namespace, String localName, int type) { 15364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Create expanded name 15374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% jjk Expanded name is bitfield-encoded as 15384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // typeID[6]nsuriID[10]localID[16]. Switch to that form, and to 15394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // accessing the ns/local via their tables rather than confusing 15404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // nsnames and expandednames. 15414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String expandedName = namespace + ":" + localName; 15424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int expandedNameID = m_nsNames.stringToIndex(expandedName); 15434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return expandedNameID; 15454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 15464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 15494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given an expanded-name ID, return the local name part. 15504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 15514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param ExpandedNameID an ID that represents an expanded-name. 15524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String Local name of this node. 15534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 15544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getLocalNameFromExpandedNameID(int ExpandedNameID) { 15554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Get expanded name 15574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String expandedName = m_localNames.indexToString(ExpandedNameID); 15584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Remove prefix from expanded name 15594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int colonpos = expandedName.indexOf(":"); 15604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String localName = expandedName.substring(colonpos+1); 15614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return localName; 15624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 15634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 15664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given an expanded-name ID, return the namespace URI part. 15674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 15684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param ExpandedNameID an ID that represents an expanded-name. 15694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String URI value of this node's namespace, or null if no 15704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * namespace was resolved. 15714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 15724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getNamespaceFromExpandedNameID(int ExpandedNameID) { 15734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String expandedName = m_localNames.indexToString(ExpandedNameID); 15754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Remove local name from expanded name 15764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int colonpos = expandedName.indexOf(":"); 15774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String nsName = expandedName.substring(0, colonpos); 15784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return nsName; 15804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 15814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 15844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * fixednames 15854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 15864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson private static final String[] fixednames= 15874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 15884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson null,null, // nothing, Element 15894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson null,"#text", // Attr, Text 15904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson "#cdata_section",null, // CDATA, EntityReference 15914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson null,null, // Entity, PI 15924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson "#comment","#document", // Comment, Document 15934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson null,"#document-fragment", // Doctype, DocumentFragment 15944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson null}; // Notation 15954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 15964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 15974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return its DOM-style node name. This will 15984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * include names such as #text or #document. 15994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 16014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String Name of this node, which may be an empty string. 16024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Document when empty string is possible... 16034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 16044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getNodeName(int nodeHandle) { 16054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 16064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (gotslot[0] & 0xFFFF); 16074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String name = fixednames[type]; 16084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (null == name) { 16094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int i=gotslot[3]; 16104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /**/System.out.println("got i="+i+" "+(i>>16)+"/"+(i&0xffff)); 16114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 16124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson name=m_localNames.indexToString(i & 0xFFFF); 16134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String prefix=m_prefixNames.indexToString(i >>16); 16144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(prefix!=null && prefix.length()>0) 16154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson name=prefix+":"+name; 16164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 16174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return name; 16184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 16194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 16204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 16214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return the XPath node name. This should be 16224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the name as described by the XPath data model, NOT the DOM-style 16234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * name. 16244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 16264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String Name of this node. 16274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 16284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getNodeNameX(int nodeHandle) {return null;} 16294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 16304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 16314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return its DOM-style localname. 16324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (As defined in Namespaces, this is the portion of the name after any 16334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * colon character) 16344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% What's the local name of something other than Element/Attr? 16364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Should this be DOM-style (undefined unless namespaced), or other? 16374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 16394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String Local name of this node. 16404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 16414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getLocalName(int nodeHandle) { 16424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 16434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (gotslot[0] & 0xFFFF); 16444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String name = ""; 16454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if ((type==ELEMENT_NODE) || (type==ATTRIBUTE_NODE)) { 16464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int i=gotslot[3]; 16474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson name=m_localNames.indexToString(i & 0xFFFF); 16484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(name==null) name=""; 16494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 16504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return name; 16514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 16524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 16534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 16544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a namespace handle, return the prefix that the namespace decl is 16554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * mapping. 16564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return the prefix used to map to the namespace. 16574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> %REVIEW% Are you sure you want "" for no prefix? </p> 16594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Should this be DOM-style (undefined unless namespaced), 16614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or other? 16624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 16644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String prefix of this node's name, or "" if no explicit 16654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * namespace prefix was given. 16664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 16674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getPrefix(int nodeHandle) { 16684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 16694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short type = (short) (gotslot[0] & 0xFFFF); 16704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String name = ""; 16714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if((type==ELEMENT_NODE) || (type==ATTRIBUTE_NODE)) { 16724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int i=gotslot[3]; 16734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson name=m_prefixNames.indexToString(i >>16); 16744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if(name==null) name=""; 16754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 16764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return name; 16774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 16784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 16794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 16804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return its DOM-style namespace URI 16814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (As defined in Namespaces, this is the declared URI which this node's 16824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * prefix -- or default in lieu thereof -- was mapped to.) 16834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the id of the node. 16854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String URI value of this node's namespace, or null if no 16864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * namespace was resolved. 16874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 16884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getNamespaceURI(int nodeHandle) {return null;} 16894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 16904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 16914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return its node value. This is mostly 16924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * as defined by the DOM, but may ignore some conveniences. 16934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 16944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 16954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node id. 16964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String Value of this node, or null if not 16974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * meaningful for this node type. 16984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 16994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getNodeValue(int nodeHandle) 17004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 17014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle, gotslot); 17024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int nodetype=gotslot[0] & 0xFF; // ###zaj use mask to get node type 17034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson String value=null; 17044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson switch (nodetype) { // ###zaj todo - document nodetypes 17064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case ATTRIBUTE_NODE: 17074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(nodeHandle+1, gotslot); 17084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case TEXT_NODE: 17094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case COMMENT_NODE: 17104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case CDATA_SECTION_NODE: 17114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson value=m_char.getString(gotslot[2], gotslot[3]); //###zaj 17124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson break; 17134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case PROCESSING_INSTRUCTION_NODE: 17144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case ELEMENT_NODE: 17154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson case ENTITY_REFERENCE_NODE: 17164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson default: 17174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson break; 17184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 17194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return value; 17204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 17214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 17234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Given a node handle, return its DOM-style node type. 17244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 17254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * %REVIEW% Generally, returning short is false economy. Return int? 17264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 17274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node id. 17284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return int Node type, as per the DOM's Node._NODE constants. 17294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 17304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public short getNodeType(int nodeHandle) { 17314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return(short) (nodes.readEntry(nodeHandle, 0) & 0xFFFF); 17324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 17334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 17354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get the depth level of this node in the tree (equals 1 for 17364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * a parentless node). 17374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 17384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node id. 17394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the number of ancestors, plus one 17404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @xsl.usage internal 17414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 17424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public short getLevel(int nodeHandle) { 17434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson short count = 0; 17444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson while (nodeHandle != 0) { 17454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson count++; 17464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodeHandle = nodes.readEntry(nodeHandle, 1); 17474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 17484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return count; 17494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 17504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ============== Document query functions ============== 17524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 17544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Tests whether DTM DOM implementation implements a specific feature and 17554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * that feature is supported by this node. 17564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 17574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param feature The name of the feature to test. 17584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param version This is the version number of the feature to test. 17594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If the version is not 17604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * specified, supporting any version of the feature will cause the 17614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * method to return <code>true</code>. 17624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return Returns <code>true</code> if the specified feature is 17634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * supported on this node, <code>false</code> otherwise. 17644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 17654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean isSupported(String feature, String version) {return false;} 17664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 17684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return the base URI of the document entity. If it is not known 17694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (because the document was parsed from a socket connection or from 17704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * standard input, for example), the value of this property is unknown. 17714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 17724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the document base URI String object or null if unknown. 17734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 17744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getDocumentBaseURI() 17754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 17764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return m_documentBaseURI; 17784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 17794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 17814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Set the base URI of the document entity. 17824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 17834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param baseURI the document base URI String object or null if unknown. 17844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 17854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setDocumentBaseURI(String baseURI) 17864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 17874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_documentBaseURI = baseURI; 17894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 17904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 17914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 17924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return the system identifier of the document entity. If 17934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * it is not known, the value of this property is unknown. 17944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 17954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node id, which can be any valid node handle. 17964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the system identifier String object or null if unknown. 17974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 17984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getDocumentSystemIdentifier(int nodeHandle) {return null;} 17994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return the name of the character encoding scheme 18024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * in which the document entity is expressed. 18034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node id, which can be any valid node handle. 18054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the document encoding String object. 18064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 18074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getDocumentEncoding(int nodeHandle) {return null;} 18084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return an indication of the standalone status of the document, 18114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * either "yes" or "no". This property is derived from the optional 18124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * standalone document declaration in the XML declaration at the 18134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * beginning of the document entity, and has no value if there is no 18144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * standalone document declaration. 18154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node id, which can be any valid node handle. 18174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the document standalone String object, either "yes", "no", or null. 18184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 18194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getDocumentStandalone(int nodeHandle) {return null;} 18204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return a string representing the XML version of the document. This 18234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * property is derived from the XML declaration optionally present at the 18244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * beginning of the document entity, and has no value if there is no XML 18254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * declaration. 18264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param documentHandle the document handle 18284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the document version String object 18304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 18314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getDocumentVersion(int documentHandle) {return null;} 18324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return an indication of 18354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * whether the processor has read the complete DTD. Its value is a 18364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * boolean. If it is false, then certain properties (indicated in their 18374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * descriptions below) may be unknown. If it is true, those properties 18384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * are never unknown. 18394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return <code>true</code> if all declarations were processed {}; 18414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>false</code> otherwise. 18424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 18434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean getDocumentAllDeclarationsProcessed() {return false;} 18444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * A document type declaration information item has the following properties: 18474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1. [system identifier] The system identifier of the external subset, if 18494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * it exists. Otherwise this property has no value. 18504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the system identifier String object, or null if there is none. 18524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 18534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getDocumentTypeDeclarationSystemIdentifier() {return null;} 18544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return the public identifier of the external subset, 18574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * normalized as described in 4.2.2 External Entities [XML]. If there is 18584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * no external subset or if it has no public identifier, this property 18594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * has no value. 18604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return the public identifier String object, or null if there is none. 18624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 18634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getDocumentTypeDeclarationPublicIdentifier() {return null;} 18644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Returns the <code>Element</code> whose <code>ID</code> is given by 18674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>elementId</code>. If no such element exists, returns 18684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>DTM.NULL</code>. Behavior is not defined if more than one element 18694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * has this <code>ID</code>. Attributes (including those 18704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * with the name "ID") are not of type ID unless so defined by DTD/Schema 18714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * information available to the DTM implementation. 18724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Implementations that do not know whether attributes are of type ID or 18734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * not are expected to return <code>DTM.NULL</code>. 18744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>%REVIEW% Presumably IDs are still scoped to a single document, 18764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * and this operation searches only within a single document, right? 18774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Wouldn't want collisions between DTMs in the same process.</p> 18784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 18794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param elementId The unique <code>id</code> value for an element. 18804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return The handle of the matching element. 18814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 18824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public int getElementById(String elementId) {return 0;} 18834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 18844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 18854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The getUnparsedEntityURI function returns the URI of the unparsed 18864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * entity with the specified name in the same document as the context 18874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * node (see [3.3 Unparsed Entities]). It returns the empty string if 18884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * there is no such entity. 18894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 18904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * XML processors may choose to use the System Identifier (if one 18914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * is provided) to resolve the entity, rather than the URI in the 18924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Public Identifier. The details are dependent on the processor, and 18934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * we would have to support some form of plug-in resolver to handle 18944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * this properly. Currently, we simply return the System Identifier if 18954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * present, and hope that it a usable URI or that our caller can 18964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * map it to one. 18974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * TODO: Resolve Public Identifiers... or consider changing function name. 18984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 18994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If we find a relative URI 19004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * reference, XML expects it to be resolved in terms of the base URI 19014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * of the document. The DOM doesn't do that for us, and it isn't 19024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * entirely clear whether that should be done here; currently that's 19034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * pushed up to a higher level of our application. (Note that DOM Level 19044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1 didn't store the document's base URI.) 19054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * TODO: Consider resolving Relative URIs. 19064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 19074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (The DOM's statement that "An XML processor may choose to 19084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * completely expand entities before the structure model is passed 19094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to the DOM" refers only to parsed entities, not unparsed, and hence 19104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * doesn't affect this function.) 19114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param name A string containing the Entity Name of the unparsed 19134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * entity. 19144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return String containing the URI of the Unparsed Entity, or an 19164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * empty string if no such entity exists. 19174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 19184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public String getUnparsedEntityURI(String name) {return null;} 19194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ============== Boolean methods ================ 19224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 19244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return true if the xsl:strip-space or xsl:preserve-space was processed 19254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * during construction of the DTM document. 19264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>%REVEIW% Presumes a 1:1 mapping from DTM to Document, since 19284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * we aren't saying which Document to query...?</p> 19294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 19304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean supportsPreStripping() {return false;} 19314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 19334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Figure out whether nodeHandle2 should be considered as being later 19344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * in the document than nodeHandle1, in Document Order as defined 19354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * by the XPath model. This may not agree with the ordering defined 19364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * by other XML applications. 19374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 19384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * There are some cases where ordering isn't defined, and neither are 19394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the results of this function -- though we'll generally return true. 19404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * TODO: Make sure this does the right thing with attribute nodes!!! 19424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle1 DOM Node to perform position comparison on. 19444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle2 DOM Node to perform position comparison on . 19454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return false if node2 comes before node1, otherwise return true. 19474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You can think of this as 19484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>(node1.documentOrderPosition <= node2.documentOrderPosition)</code>. 19494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 19504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean isNodeAfter(int nodeHandle1, int nodeHandle2) {return false;} 19514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 19534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2. [element content whitespace] A boolean indicating whether the 19544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * character is white space appearing within element content (see [XML], 19554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2.10 "White Space Handling"). Note that validating XML processors are 19564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * required by XML 1.0 to provide this information. If there is no 19574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * declaration for the containing element, this property has no value for 19584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * white space characters. If no declaration has been read, but the [all 19594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * declarations processed] property of the document information item is 19604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * false (so there may be an unread declaration), then the value of this 19614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * property is unknown for white space characters. It is always false for 19624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * characters that are not white space. 19634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle the node ID. 19654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return <code>true</code> if the character data is whitespace; 19664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>false</code> otherwise. 19674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 19684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean isCharacterElementContentWhitespace(int nodeHandle) {return false;} 19694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 19714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 10. [all declarations processed] This property is not strictly speaking 19724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * part of the infoset of the document. Rather it is an indication of 19734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * whether the processor has read the complete DTD. Its value is a 19744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * boolean. If it is false, then certain properties (indicated in their 19754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * descriptions below) may be unknown. If it is true, those properties 19764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * are never unknown. 19774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param documentHandle A node handle that must identify a document. 19794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return <code>true</code> if all declarations were processed; 19804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>false</code> otherwise. 19814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 19824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean isDocumentAllDeclarationsProcessed(int documentHandle) {return false;} 19834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 19854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 5. [specified] A flag indicating whether this attribute was actually 19864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * specified in the start-tag of its element, or was defaulted from the 19874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DTD. 19884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 19894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param attributeHandle the attribute handle 19904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return <code>true</code> if the attribute was specified; 19914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>false</code> if it was defaulted. 19924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 19934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean isAttributeSpecified(int attributeHandle) {return false;} 19944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ========== Direct SAX Dispatch, for optimization purposes ======== 19964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 19974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 19984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Directly call the 19994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * characters method on the passed ContentHandler for the 20004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * string-value of the given node (see http://www.w3.org/TR/xpath#data-model 20014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * for the definition of a node's string-value). Multiple calls to the 20024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ContentHandler's characters methods may well occur for a single call to 20034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * this method. 20044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node ID. 20064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param ch A non-null reference to a ContentHandler. 20074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @throws org.xml.sax.SAXException 20094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 20104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void dispatchCharactersEvents( 20114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) 20124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException {} 20134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 20154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Directly create SAX parser events from a subtree. 20164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node ID. 20184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param ch A non-null reference to a ContentHandler. 20194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @throws org.xml.sax.SAXException 20214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 20224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch) 20244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson throws org.xml.sax.SAXException {} 20254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 20274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return an DOM node for the given node. 20284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param nodeHandle The node ID. 20304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return A node representation of the DTM node. 20324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 20334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public org.w3c.dom.Node getNode(int nodeHandle) 20344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 20354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 20364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 20374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ==== Construction methods (may not be supported by some implementations!) ===== 20394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %REVIEW% jjk: These probably aren't the right API. At the very least 20404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // they need to deal with current-insertion-location and end-element 20414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // issues. 20424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 20444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Append a child to the end of the child list of the current node. Please note that the node 20454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * is always cloned if it is owned by another document. 20464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>%REVIEW% "End of the document" needs to be defined more clearly. 20484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Does it become the last child of the Document? Of the root element?</p> 20494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param newChild Must be a valid new node handle. 20514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param clone true if the child should be cloned into the document. 20524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param cloneDepth if the clone argument is true, specifies that the 20534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * clone should include all it's children. 20544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 20554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void appendChild(int newChild, boolean clone, boolean cloneDepth) { 20564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson boolean sameDoc = ((newChild & DOCHANDLE_MASK) == m_docHandle); 20574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (clone || !sameDoc) { 20584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } else { 20604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 20624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 20634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 20654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Append a text node child that will be constructed from a string, 20664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to the end of the document. 20674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p>%REVIEW% "End of the document" needs to be defined more clearly. 20694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Does it become the last child of the Document? Of the root element?</p> 20704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param str Non-null reference to a string. 20724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 20734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void appendTextChild(String str) { 20744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ###shs Think more about how this differs from createTextNode 20754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //%TBD% 20764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 20774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //================================================================ 20804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // ==== BUILDER methods ==== 20814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% jjk: SHOULD PROBABLY BE INLINED, unless we want to support 20824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // both SAX1 and SAX2 and share this logic between them. 20834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 20844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Append a text child at the current insertion point. Assumes that the 20854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * actual content of the text has previously been appended to the m_char 20864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * buffer (shared with the builder). 20874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 20884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param m_char_current_start int Starting offset of node's content in m_char. 20894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param contentLength int Length of node's content in m_char. 20904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 20914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendTextChild(int m_char_current_start,int contentLength) 20924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 20934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // create a Text Node 20944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% may be possible to combine with appendNode()to replace the next chunk of code 20954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w0 = TEXT_NODE; 20964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W1: Parent 20974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w1 = currentParent; 20984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W2: Start position within m_char 20994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w2 = m_char_current_start; 21004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W3: Length of the full string 21014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w3 = contentLength; 21024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int ourslot = appendNode(w0, w1, w2, w3); 21044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSibling = ourslot; 21054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 21064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Append a comment child at the current insertion point. Assumes that the 21084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * actual content of the comment has previously been appended to the m_char 21094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * buffer (shared with the builder). 21104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 21114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param m_char_current_start int Starting offset of node's content in m_char. 21124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param contentLength int Length of node's content in m_char. 21134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 21144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendComment(int m_char_current_start,int contentLength) 21154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 21164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // create a Comment Node 21174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% may be possible to combine with appendNode()to replace the next chunk of code 21184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w0 = COMMENT_NODE; 21194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W1: Parent 21204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w1 = currentParent; 21214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W2: Start position within m_char 21224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w2 = m_char_current_start; 21234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W3: Length of the full string 21244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w3 = contentLength; 21254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int ourslot = appendNode(w0, w1, w2, w3); 21274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSibling = ourslot; 21284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 21294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Append an Element child at the current insertion point. This 21324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Element then _becomes_ the insertion point; subsequent appends 21334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * become its lastChild until an appendEndElement() call is made. 21344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 21354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Assumes that the symbols (local name, namespace URI and prefix) 21364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * have already been added to the pools 21374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 21384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Note that this _only_ handles the Element node itself. Attrs and 21394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * namespace nodes are unbundled in the ContentHandler layer 21404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * and appended separately. 21414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 21424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param namespaceIndex: Index within the namespaceURI string pool 21434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param localNameIndex Index within the local name string pool 21444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param prefixIndex: Index within the prefix string pool 21454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 21464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendStartElement(int namespaceIndex,int localNameIndex, int prefixIndex) 21474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 21484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // do document root node creation here on the first element, create nodes for 21494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // this element and its attributes, store the element, namespace, and attritute 21504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // name indexes to the nodes array, keep track of the current node and parent 21514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // element used 21524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W0 High: Namespace Low: Node Type 21544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w0 = (namespaceIndex << 16) | ELEMENT_NODE; 21554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W1: Parent 21564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w1 = currentParent; 21574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W2: Next (initialized as 0) 21584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w2 = 0; 21594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W3: Tagname high: prefix Low: local name 21604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w3 = localNameIndex | prefixIndex<<16; 21614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /**/System.out.println("set w3="+w3+" "+(w3>>16)+"/"+(w3&0xffff)); 21624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson //int ourslot = nodes.appendSlot(w0, w1, w2, w3); 21644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int ourslot = appendNode(w0, w1, w2, w3); 21654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson currentParent = ourslot; 21664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSibling = 0; 21674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // set the root element pointer when creating the first element node 21694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (m_docElement == NULL) 21704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_docElement = ourslot; 21714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 21724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Append a Namespace Declaration child at the current insertion point. 21744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Assumes that the symbols (namespace URI and prefix) have already been 21754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * added to the pools 21764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 21774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param prefixIndex: Index within the prefix string pool 21784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param namespaceIndex: Index within the namespaceURI string pool 21794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param isID: If someone really insists on writing a bad DTD, it is 21804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * theoretically possible for a namespace declaration to also be declared 21814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * as being a node ID. I don't really want to support that stupidity, 21824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * but I'm not sure we can refuse to accept it. 21834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 21844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendNSDeclaration(int prefixIndex, int namespaceIndex, 21854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson boolean isID) 21864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 21874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %REVIEW% I'm assigning this node the "namespace for namespaces" 21884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // which the DOM defined. It is expected that the Namespace spec will 21894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // adopt this as official. It isn't strictly needed since it's implied 21904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // by the nodetype, but for now... 21914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %REVIEW% Prefix need not be recorded; it's implied too. But 21934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // recording it might simplify the design. 21944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% isID is not currently honored. 21964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson final int namespaceForNamespaces=m_nsNames.stringToIndex("http://www.w3.org/2000/xmlns/"); 21984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 21994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W0 High: Namespace Low: Node Type 22004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w0 = NAMESPACE_NODE | (m_nsNames.stringToIndex("http://www.w3.org/2000/xmlns/")<<16); 22014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W1: Parent 22034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w1 = currentParent; 22044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W2: CURRENTLY UNUSED -- It's next-sib in attrs, but we have no kids. 22054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w2 = 0; 22064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W3: namespace name 22074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w3 = namespaceIndex; 22084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Add node 22094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int ourslot = appendNode(w0, w1, w2, w3); 22104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSibling = ourslot; // Should attributes be previous siblings 22114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSiblingWasParent = false; 22124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return ;//(m_docHandle | ourslot); 22134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 22144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Append an Attribute child at the current insertion 22164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * point. Assumes that the symbols (namespace URI, local name, and 22174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * prefix) have already been added to the pools, and that the content has 22184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * already been appended to m_char. Note that the attribute's content has 22194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * been flattened into a single string; DTM does _NOT_ attempt to model 22204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the details of entity references within attribute values. 22214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 22224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param namespaceIndex int Index within the namespaceURI string pool 22234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param localNameIndex int Index within the local name string pool 22244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param prefixIndex int Index within the prefix string pool 22254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param isID boolean True if this attribute was declared as an ID 22264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * (for use in supporting getElementByID). 22274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param m_char_current_start int Starting offset of node's content in m_char. 22284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param contentLength int Length of node's content in m_char. 22294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 22304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendAttribute(int namespaceIndex, int localNameIndex, int prefixIndex, 22314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson boolean isID, 22324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int m_char_current_start, int contentLength) 22334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 22344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% isID is not currently honored. 22354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W0 High: Namespace Low: Node Type 22374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w0 = ATTRIBUTE_NODE | namespaceIndex<<16; 22384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W1: Parent 22404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w1 = currentParent; 22414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W2: Next (not yet resolved) 22424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w2 = 0; 22434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W3: Tagname high: prefix Low: local name 22444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int w3 = localNameIndex | prefixIndex<<16; 22454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /**/System.out.println("set w3="+w3+" "+(w3>>16)+"/"+(w3&0xffff)); 22464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Add node 22474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson int ourslot = appendNode(w0, w1, w2, w3); 22484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSibling = ourslot; // Should attributes be previous siblings 22494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Attribute's content is currently appended as a Text Node 22514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W0: Node Type 22534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson w0 = TEXT_NODE; 22544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W1: Parent 22554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson w1 = ourslot; 22564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W2: Start Position within buffer 22574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson w2 = m_char_current_start; 22584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // W3: Length 22594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson w3 = contentLength; 22604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson appendNode(w0, w1, w2, w3); 22614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Attrs are Parents 22634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSiblingWasParent = true; 22644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return ;//(m_docHandle | ourslot); 22654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 22664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 22684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This returns a stateless "traverser", that can navigate over an 22694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * XPath axis, though not in document order. 22704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 22714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param axis One of Axes.ANCESTORORSELF, etc. 22724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 22734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return A DTMAxisIterator, or null if the given axis isn't supported. 22744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 22754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DTMAxisTraverser getAxisTraverser(final int axis) 22764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 22774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 22784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 22794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 22814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This is a shortcut to the iterators that implement the 22824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * supported XPath axes (only namespace::) is not supported. 22834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Returns a bare-bones iterator that must be initialized 22844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * with a start node (using iterator.setStartNode()). 22854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 22864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param axis One of Axes.ANCESTORORSELF, etc. 22874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 22884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return A DTMAxisIterator, or null if the given axis isn't supported. 22894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 22904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DTMAxisIterator getAxisIterator(final int axis) 22914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 22924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% 22934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 22944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 22954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 22964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 22974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get an iterator that can navigate over an XPath Axis, predicated by 22984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the extended type ID. 22994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 23004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 23014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param axis 23024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param type An extended type ID. 23034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 23044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return A DTMAxisIterator, or null if the given axis isn't supported. 23054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 23064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DTMAxisIterator getTypedAxisIterator(final int axis, final int type) 23074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% 23094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 23104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Terminate the element currently acting as an insertion point. Subsequent 23144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * insertions will occur as the last child of this element's parent. 23154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 23164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendEndElement() 23174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // pop up the stacks 23194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson if (previousSiblingWasParent) 23214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.writeEntry(previousSibling, 2, NULL); 23224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Pop parentage 23244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSibling = currentParent; 23254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson nodes.readSlot(currentParent, gotslot); 23264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson currentParent = gotslot[1] & 0xFFFF; 23274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // The element just being finished will be 23294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // the previous sibling for the next operation 23304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson previousSiblingWasParent = true; 23314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // Pop a level of namespace table 23334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // namespaceTable.removeLastElem(); 23344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** Starting a new document. Perform any resets/initialization 23374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * not already handled. 23384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 23394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendStartDocument() 23404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% reset slot 0 to indicate ChunkedIntArray reuse or wait for 23434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // the next initDocument(). 23444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson m_docElement = NULL; // reset nodeHandle to the root of the actual dtm doc content 23454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson initDocument(0); 23464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** All appends to this document have finished; do whatever final 23494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * cleanup is needed. 23504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * */ 23514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson void appendEndDocument() 23524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson done = true; 23544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // %TBD% may need to notice the last slot number and slot count to avoid 23554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson // residual data from provious use of this DTM 23564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 23594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * For the moment all the run time properties are ignored by this 23604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * class. 23614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 23624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param property a <code>String</code> value 23634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param value an <code>Object</code> value 23644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 23654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setProperty(String property, Object value) 23664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 23704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Source information is not handled yet, so return 23714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <code>null</code> here. 23724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 23734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param node an <code>int</code> value 23744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return null 23754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 23764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public SourceLocator getSourceLocatorFor(int node) 23774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson return null; 23794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 23834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * A dummy routine to satisify the abstract interface. If the DTM 23844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * implememtation that extends the default base requires notification 23854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * of registration, they can override this method. 23864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 23874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void documentRegistration() 23884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 23914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 23924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * A dummy routine to satisify the abstract interface. If the DTM 23934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * implememtation that extends the default base requires notification 23944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * when the document is being released, they can override this method 23954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 23964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void documentRelease() 23974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 23984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 23994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 24004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 24014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Migrate a DTM built with an old DTMManager to a new DTMManager. 24024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * After the migration, the new DTMManager will treat the DTM as 24034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * one that is built by itself. 24044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This is used to support DTM sharing between multiple transformations. 24054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param manager the DTMManager 24064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 24074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void migrateTo(DTMManager manager) 24084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson { 24094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson } 24104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 24114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson} 2412