📄 saximpl.java
字号:
NodeValueIterator clone = (NodeValueIterator)super.clone(); clone._isRestartable = false; clone._source = _source.cloneIterator(); clone._value = _value; clone._op = _op; return clone.reset(); } catch (CloneNotSupportedException e) { BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR, e.toString()); return null; } } public void setRestartable(boolean isRestartable) { _isRestartable = isRestartable; _source.setRestartable(isRestartable); } public DTMAxisIterator reset() { _source.reset(); return resetPosition(); } public int next() { int node; while ((node = _source.next()) != END) { String val = getStringValueX(node); if (_value.equals(val) == _op) { if (_returnType == RETURN_CURRENT) { return returnNode(node); } else { return returnNode(getParent(node)); } } } return END; } public DTMAxisIterator setStartNode(int node) { if (_isRestartable) { _source.setStartNode(_startNode = node); return resetPosition(); } return this; } public void setMark() { _source.setMark(); } public void gotoMark() { _source.gotoMark(); } } // end NodeValueIterator public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iterator, int type, String value, boolean op) { return(DTMAxisIterator)(new NodeValueIterator(iterator, type, value, op)); } /** * Encapsulates an iterator in an OrderedIterator to ensure node order */ public DTMAxisIterator orderNodes(DTMAxisIterator source, int node) { return new DupFilterIterator(source); } /** * Returns singleton iterator containg the document root * Works for them main document (mark == 0). It cannot be made * to point to any other node through setStartNode(). */ public DTMAxisIterator getIterator() { return new SingletonIterator(getDocument(), true); } /** * Get mapping from DOM namespace types to external namespace types */ public int getNSType(int node) { String s = getNamespaceURI(node); if (s == null) { return 0; } int eType = getIdForNamespace(s); return ((Integer)_nsIndex.get(new Integer(eType))).intValue(); } /** * Returns the namespace type of a specific node */ public int getNamespaceType(final int node) { return super.getNamespaceType(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) { return getGeneralizedType(name, true); } /** * 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); } /** * Get mapping from DOM element/attribute types to external types */ public short[] getMapping(String[] names, String[] uris, int[] types) { // Delegate the work to getMapping2 if the document is not fully built. // Some of the processing has to be different in this case. if (_namesSize < 0) { return getMapping2(names, uris, types); } int i; final int namesLength = names.length; final int exLength = m_expandedNameTable.getSize(); final short[] result = new short[exLength]; // primitive types map to themselves for (i = 0; i < DTM.NTYPES; i++) { result[i] = (short)i; } for (i = NTYPES; i < exLength; i++) { result[i] = m_expandedNameTable.getType(i); } // actual mapping of caller requested names for (i = 0; i < namesLength; i++) { int genType = m_expandedNameTable.getExpandedTypeID(uris[i], names[i], types[i], true); if (genType >= 0 && genType < exLength) { result[genType] = (short)(i + DTM.NTYPES); } } return result; } /** * 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); } /** * Get mapping from DOM element/attribute types to external types. * This method is used when the document is not fully built. */ private short[] getMapping2(String[] names, String[] uris, int[] types) { int i; final int namesLength = names.length; final int exLength = m_expandedNameTable.getSize(); int[] generalizedTypes = null; if (namesLength > 0) { generalizedTypes = new int[namesLength]; } int resultLength = exLength; for (i = 0; i < namesLength; i++) { // When the document is not fully built, the searchOnly // flag should be set to false. That means we should add // the type if it is not already in the expanded name table. //generalizedTypes[i] = getGeneralizedType(names[i], false); generalizedTypes[i] = m_expandedNameTable.getExpandedTypeID(uris[i], names[i], types[i], false); if (_namesSize < 0 && generalizedTypes[i] >= resultLength) { resultLength = generalizedTypes[i] + 1; } } final short[] result = new short[resultLength]; // primitive types map to themselves for (i = 0; i < DTM.NTYPES; i++) { result[i] = (short)i; } for (i = NTYPES; i < exLength; i++) { result[i] = m_expandedNameTable.getType(i); } // actual mapping of caller requested names for (i = 0; i < namesLength; i++) { int genType = generalizedTypes[i]; if (genType >= 0 && genType < resultLength) { result[genType] = (short)(i + DTM.NTYPES); } } return(result); } /** * Get mapping from DOM namespace types to external namespace types */ public short[] getNamespaceMapping(String[] namespaces) { int i; final int nsLength = namespaces.length; final int mappingLength = _uriCount; final short[] result = new short[mappingLength]; // Initialize all entries to -1 for (i=0; i<mappingLength; i++) { result[i] = (short)(-1); } for (i=0; i<nsLength; i++) { int eType = getIdForNamespace(namespaces[i]); Integer type = (Integer)_nsIndex.get(new Integer(eType)); if (type != null) { result[type.intValue()] = (short)i; } } return(result); } /** * Get mapping from external namespace types to DOM namespace types */ public short[] getReverseNamespaceMapping(String[] namespaces) { int i; final int length = namespaces.length; final short[] result = new short[length]; for (i = 0; i < length; i++) { int eType = getIdForNamespace(namespaces[i]); Integer type = (Integer)_nsIndex.get(new Integer(eType)); result[i] = (type == null) ? -1 : type.shortValue(); } return result; } /** * Construct a SAXImpl object using the default block size. */ public SAXImpl(XSLTCDTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, boolean buildIdIndex) { this(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory, doIndexing, DEFAULT_BLOCKSIZE, buildIdIndex, false); } /** * Construct a SAXImpl object using the given block size. */ public SAXImpl(XSLTCDTMManager mgr, Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean buildIdIndex, boolean newNameTable) { super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory, doIndexing, blocksize, false, buildIdIndex, newNameTable); _dtmManager = mgr; _size = blocksize; // Use a smaller size for the space stack if the blocksize is small _xmlSpaceStack = new int[blocksize <= 64 ? 4 : 64]; /* From DOMBuilder */ _xmlSpaceStack[0] = DTMDefaultBase.ROOTNODE; // If the input source is DOMSource, set the _document field and // create the node2Ids table. if (source instanceof DOMSource) { _hasDOMSource = true; DOMSource domsrc = (DOMSource)source; Node node = domsrc.getNode(); if (node instanceof Document) { _document = (Document)node; } else { _document = node.getOwnerDocument(); } _node2Ids = new Hashtable(); } } /** * Migrate a DTM built with an old DTMManager to a new DTMManager. * After the migration, the new DTMManager will treat the DTM as * one that is built by itself. * This is used to support DTM sharing between multiple transformations. * @param manager the DTMManager */ public void migrateTo(DTMManager manager) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -