/** * The Expanded Name table holds all of our Node names. The Base class * will add the common element types, need to call this function from * the derived class. * */ protected void createExpandedNameTable( ) { m_Document_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_DOCUMENT, DTM.DOCUMENT_NODE); m_TextNode_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_TEXT_NODE, DTM.TEXT_NODE); }
/** * Given an expanded name represented by namespace, local name and node type, * return an ID. If the expanded-name does not exist in the internal tables, * the entry will be created, and the ID will be returned. Any additional * nodes that are created that have this expanded name will use this ID. * * @param namespace The namespace * @param localName The local name * @param type The node type * * @return the expanded-name id of the node. */ public int getExpandedTypeID(String namespace, String localName, int type) { return getExpandedTypeID(namespace, localName, type, false); }
/** * Given an expanded name represented by namespace, local name and node type, * return an ID. If the expanded-name does not exist in the internal tables, * the entry will be created, and the ID will be returned. Any additional * nodes that are created that have this expanded name will use this ID. * * @param namespace The namespace * @param localName The local name * @param type The node type * * @return the expanded-name id of the node. */ public int getExpandedTypeID(String namespace, String localName, int type) { return getExpandedTypeID(namespace, localName, type, false); }
/** * Get mapping from external element/attribute types to DOM types */ public int[] getReverseMapping(String[] names, String[] uris, int[] types) { int i; final int[] result = new int[names.length + DTM.NTYPES]; // primitive types map to themselves for (i = 0; i < DTM.NTYPES; i++) { result[i] = i; } // caller's types map into appropriate dom types for (i = 0; i < names.length; i++) { int type = m_expandedNameTable.getExpandedTypeID(uris[i], names[i], types[i], true); result[i+DTM.NTYPES] = type; } return(result); }
/** * Given an expanded name, return an ID. If the expanded-name does not * exist in the internal tables, the entry will be created, and the ID will * be returned. Any additional nodes that are created that have this * expanded name will use this ID. * * @param type The simple type, i.e. one of ELEMENT, ATTRIBUTE, etc. * * @param namespace The namespace URI, which may be null, may be an empty * string (which will be the same as null), or may be a * namespace URI. * @param localName The local name string, which must be a valid * <a href="http://www.w3.org/TR/REC-xml-names/">NCName</a>. * * @return the expanded-name id of the node. */ public int getExpandedTypeID(String namespace, String localName, int type) { ExpandedNameTable ent = m_expandedNameTable; return ent.getExpandedTypeID(namespace, localName, type); }
/** * Given an expanded name, return an ID. If the expanded-name does not * exist in the internal tables, the entry will be created, and the ID will * be returned. Any additional nodes that are created that have this * expanded name will use this ID. * * @param type The simple type, i.e. one of ELEMENT, ATTRIBUTE, etc. * * @param namespace The namespace URI, which may be null, may be an empty * string (which will be the same as null), or may be a * namespace URI. * @param localName The local name string, which must be a valid * <a href="http://www.w3.org/TR/REC-xml-names/">NCName</a>. * * @return the expanded-name id of the node. */ public int getExpandedTypeID(String namespace, String localName, int type) { ExpandedNameTable ent = m_expandedNameTable; return ent.getExpandedTypeID(namespace, localName, type); }
/** * Populate the Expanded Name Table with the Node that we will use. * Keep a reference of each of the types for access speed. * @return */ protected void createExpandedNameTable( ) { super.createExpandedNameTable(); m_ErrorExt_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_EXT_ERROR, DTM.ELEMENT_NODE); m_SQLError_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_SQL_ERROR, DTM.ELEMENT_NODE); m_Message_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_MESSAGE, DTM.ELEMENT_NODE); m_Code_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_CODE, DTM.ELEMENT_NODE); m_State_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_STATE, DTM.ELEMENT_NODE); m_SQLWarning_TypeID = m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_SQL_WARNING, DTM.ELEMENT_NODE); }
/** * Sets up a translet-to-dom type mapping table */ private int[] setupMapping(String[] names, String[] uris, int[] types, int nNames) { // Padding with number of names, because they // may need to be added, i.e for RTFs. See copy03 final int[] result = new int[m_expandedNameTable.getSize()]; for (int i = 0; i < nNames; i++) { //int type = getGeneralizedType(namesArray[i]); int type = m_expandedNameTable.getExpandedTypeID(uris[i], names[i], types[i], false); result[type] = type; } return result; }
/** * Returns the internal type associated with an expanded QName */ public int getGeneralizedType(final String name, boolean searchOnly) { String lName, ns = null; int index = -1; int code; // Is there a prefix? if ((index = name.lastIndexOf(':'))> -1) { ns = name.substring(0, index); } // Local part of name is after colon. lastIndexOf returns -1 if // there is no colon, so lNameStartIdx will be zero in that case. int lNameStartIdx = index+1; // Distinguish attribute and element names. Attribute has @ before // local part of name. if (name.charAt(lNameStartIdx) == '@') { code = DTM.ATTRIBUTE_NODE; lNameStartIdx++; } else { code = DTM.ELEMENT_NODE; } // Extract local name lName = (lNameStartIdx == 0) ? name : name.substring(lNameStartIdx); return m_expandedNameTable.getExpandedTypeID(ns, lName, code, searchOnly); }
/** * Given a qualified name, return an integer ID that can be * quickly compared. * * @param qname a qualified name object, must not be null. * * @return the expanded-name id of the qualified name. */ public int getQNameID(QName qname) { return m_ent.getExpandedTypeID(qname.getNamespace(), qname.getLocalName(), // The type doesn't matter for our // purposes. org.apache.xml.dtm.DTM.ELEMENT_NODE); }
/** * Given a qualified name, return an integer ID that can be * quickly compared. * * @param qname a qualified name object, must not be null. * * @return the expanded-name id of the qualified name. */ public int getQNameID(QName qname) { return m_ent.getExpandedTypeID(qname.getNamespace(), qname.getLocalName(), // The type doesn't matter for our // purposes. org.apache.xml.dtm.DTM.ELEMENT_NODE); }
/** * Receive notification of the beginning of the document. * * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#startDocument */ public void startDocument() throws SAXException { if (DEBUG) System.out.println("startDocument"); int doc = addNode(DTM.DOCUMENT_NODE, m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE), DTM.NULL, DTM.NULL, 0, true); m_parents.push(doc); m_previous = DTM.NULL; m_contextIndexes.push(m_prefixMappings.size()); // for the next element. }
/** * Receive notification of the beginning of the document. * * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#startDocument */ public void startDocument() throws SAXException { if (DEBUG) System.out.println("startDocument"); int doc = addNode(DTM.DOCUMENT_NODE, m_expandedNameTable.getExpandedTypeID(DTM.DOCUMENT_NODE), DTM.NULL, DTM.NULL, 0, true); m_parents.push(doc); m_previous = DTM.NULL; m_contextIndexes.push(m_prefixMappings.size()); // for the next element. }
/** * Report an XML comment anywhere in the document. * * <p>This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read).</p> * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. * @throws SAXException The application may raise an exception. */ public void comment(char ch[], int start, int length) throws SAXException { if (m_insideDTD) // ignore comments if we're inside the DTD return; charactersFlush(); int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE); // For now, treat comments as strings... I guess we should do a // seperate FSB buffer instead. int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start, length)); m_previous = addNode(DTM.COMMENT_NODE, exName, m_parents.peek(), m_previous, dataIndex, false); }
/** * Report an XML comment anywhere in the document. * * <p>This callback will be used for comments inside or outside the * document element, including comments in the external DTD * subset (if read).</p> * * @param ch An array holding the characters in the comment. * @param start The starting position in the array. * @param length The number of characters to use from the array. * @throws SAXException The application may raise an exception. */ public void comment(char ch[], int start, int length) throws SAXException { if (m_insideDTD) // ignore comments if we're inside the DTD return; charactersFlush(); int exName = m_expandedNameTable.getExpandedTypeID(DTM.COMMENT_NODE); // For now, treat comments as strings... I guess we should do a // seperate FSB buffer instead. int dataIndex = m_valuesOrPrefixes.stringToIndex(new String(ch, start, length)); m_previous = addNode(DTM.COMMENT_NODE, exName, m_parents.peek(), m_previous, dataIndex, false); }
int genType = m_expandedNameTable.getExpandedTypeID(uris[i], names[i], types[i],
/** * Receive notification of a processing instruction. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions for each * processing instruction, such as setting status variables or * invoking other methods.</p> * * @param target The processing instruction target. * @param data The processing instruction data, or null if * none is supplied. * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#processingInstruction */ public void processingInstruction(String target, String data) throws SAXException { if (DEBUG) System.out.println("processingInstruction: target: " + target +", data: "+data); charactersFlush(); int exName = m_expandedNameTable.getExpandedTypeID(null, target, DTM.PROCESSING_INSTRUCTION_NODE); int dataIndex = m_valuesOrPrefixes.stringToIndex(data); m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName, m_parents.peek(), m_previous, dataIndex, false); }
/** * Receive notification of a processing instruction. * * <p>By default, do nothing. Application writers may override this * method in a subclass to take specific actions for each * processing instruction, such as setting status variables or * invoking other methods.</p> * * @param target The processing instruction target. * @param data The processing instruction data, or null if * none is supplied. * @throws SAXException Any SAX exception, possibly * wrapping another exception. * @see org.xml.sax.ContentHandler#processingInstruction */ public void processingInstruction(String target, String data) throws SAXException { if (DEBUG) System.out.println("processingInstruction: target: " + target +", data: "+data); charactersFlush(); int exName = m_expandedNameTable.getExpandedTypeID(null, target, DTM.PROCESSING_INSTRUCTION_NODE); int dataIndex = m_valuesOrPrefixes.stringToIndex(data); m_previous = addNode(DTM.PROCESSING_INSTRUCTION_NODE, exName, m_parents.peek(), m_previous, dataIndex, false); }
int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE); int dataIndex = m_data.size();
int exName = m_expandedNameTable.getExpandedTypeID(DTM.TEXT_NODE); int dataIndex = m_data.size();