resulttreehandler.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,929 行 · 第 1/4 页
JAVA
1,929 行
{ GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_CHARACTERS, ch, start, length); m_tracer.fireGenerateEvent(ge); } } public void characters(org.w3c.dom.Node node) throws org.xml.sax.SAXException { flushPending(true); if(m_isTransformClient) m_snapshot.m_currentNode = node; String data = node.getNodeValue(); char [] ch = null; int length = 0; if (data != null) { ch = data.toCharArray(); length = data.length(); m_contentHandler.characters(ch, 0, length); } if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_CHARACTERS, ch, 0, length); m_tracer.fireGenerateEvent(ge); } if(m_isTransformClient) m_snapshot.m_currentNode = null; } /** * Bottleneck the ignorableWhitespace event. * * @param ch Array of characters to process * @param start start of characters in the array * @param length Number of characters in the array * * @throws org.xml.sax.SAXException */ public void ignorableWhitespace(char ch[], int start, int length) throws org.xml.sax.SAXException { if (m_docPending && XMLCharacterRecognizer.isWhiteSpace(ch, start, length)) return; flushPending(true); m_contentHandler.ignorableWhitespace(ch, start, length); if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_IGNORABLEWHITESPACE, ch, start, length); m_tracer.fireGenerateEvent(ge); } } /** * Bottleneck the processingInstruction event. * * @param target Processing instruction target name * @param data Processing instruction data * * @throws org.xml.sax.SAXException */ public void processingInstruction(String target, String data) throws org.xml.sax.SAXException { flushPending(true); m_contentHandler.processingInstruction(target, data); if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_PI, target, data); m_tracer.fireGenerateEvent(ge); } } /** * Bottleneck the comment event. * * @param data Comment data * * @throws org.xml.sax.SAXException */ public void comment(String data) throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.comment(data.toCharArray(), 0, data.length()); } if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_COMMENT, data); m_tracer.fireGenerateEvent(ge); } } /** * Bottleneck the comment event. * * @param ch Character array with comment data * @param start start of characters in the array * @param length number of characters in the array * * @throws org.xml.sax.SAXException */ public void comment(char ch[], int start, int length) throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.comment(ch, start, length); } if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_COMMENT, new String(ch, start, length)); m_tracer.fireGenerateEvent(ge); } } /** * Entity reference event. * * @param name Name of entity * * @throws org.xml.sax.SAXException */ public void entityReference(String name) throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.startEntity(name); m_lexicalHandler.endEntity(name); } if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_ENTITYREF, name); m_tracer.fireGenerateEvent(ge); } } /** * Start an entity. * * @param name Name of the entity * * @throws org.xml.sax.SAXException */ public void startEntity(String name) throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.startEntity(name); } } /** * End an entity. * * @param name Name of the entity * * @throws org.xml.sax.SAXException */ public void endEntity(String name) throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.endEntity(name); } if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_ENTITYREF, name); m_tracer.fireGenerateEvent(ge); } } /** * Start the DTD. * * @param s1 The document type name. * @param s2 The declared public identifier for the * external DTD subset, or null if none was declared. * @param s3 The declared system identifier for the * external DTD subset, or null if none was declared. * * @throws org.xml.sax.SAXException */ public void startDTD(String s1, String s2, String s3) throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.startDTD(s1, s2, s3); } } /** * End the DTD. * * @throws org.xml.sax.SAXException */ public void endDTD() throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.endDTD(); } } /** * Start the CDATACharacters. * * @throws org.xml.sax.SAXException */ public void startCDATA() throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.startCDATA(); } } /** * End the CDATA characters. * * @throws org.xml.sax.SAXException */ public void endCDATA() throws org.xml.sax.SAXException { flushPending(true); if (null != m_lexicalHandler) { m_lexicalHandler.endCDATA(); } } /** * Receive notification of a skipped entity. * * <p>The Parser will invoke this method once for each entity * skipped. Non-validating processors may skip entities if they * have not seen the declarations (because, for example, the * entity was declared in an external DTD subset). All processors * may skip external entities, depending on the values of the * http://xml.org/sax/features/external-general-entities and the * http://xml.org/sax/features/external-parameter-entities * properties.</p> * * @param name The name of the skipped entity. If it is a * parameter entity, the name will begin with '%'. * @throws org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. */ public void skippedEntity(String name) throws org.xml.sax.SAXException{} /** * Set whether Namespace declarations have been added to * this element * * * @param b Flag indicating whether Namespace declarations * have been added to this element */ public void setNSDeclsHaveBeenAdded(boolean b) { m_nsDeclsHaveBeenAdded = b; } /** * Flush the event. * * @throws TransformerException * * @throws org.xml.sax.SAXException */ void flushDocEvent() throws org.xml.sax.SAXException { if (m_docPending) { m_contentHandler.startDocument(); if (null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_STARTDOCUMENT); m_tracer.fireGenerateEvent(ge); } if (m_contentHandler instanceof TransformerClient) { ((TransformerClient) m_contentHandler).setTransformState(this); } m_docPending = false; } } /** * Flush the event. * * @throws SAXException */ void flushElem() throws org.xml.sax.SAXException { if (m_elemIsPending) { if (null != m_name) { try { m_contentHandler.startElement(m_url, m_localName, m_name, m_attributes); } catch(Exception re) { // If we don't do this, and the exception is a RuntimeException, // good line numbers of where the exception occured in the stylesheet // won't get reported. I tried just catching RuntimeException, but // for whatever reason it didn't seem to catch. // Fix for Christina's DOMException error problem. throw new SAXParseException(re.getMessage(), m_transformer.getCurrentElement().getPublicId(), m_transformer.getCurrentElement().getSystemId(), m_transformer.getCurrentElement().getLineNumber(), m_transformer.getCurrentElement().getColumnNumber(), re); } if(null != m_tracer) { GenerateEvent ge = new GenerateEvent(m_transformer, GenerateEvent.EVENTTYPE_STARTELEMENT, m_name, m_attributes); m_tracer.fireGenerateEvent(ge); } if(m_isTransformClient) m_snapshot.m_currentNode = null; } m_elemIsPending = false; m_attributes.clear(); m_nsDeclsHaveBeenAdded = false; m_name = null; m_url = null; m_localName = null; m_namespaces = null; // super.flush(); } } /** * Flush the pending element. * * @throws org.xml.sax.SAXException */ public final void flushPending() throws org.xml.sax.SAXException { flushPending(true); } /** * Flush the pending element, and any attributes associated with it. * * NOTE: If there are attributes but _no_ pending element (which can * happen if the user's stylesheet is doing something inappropriate), * we still want to make sure they are flushed. * * @param type Event type * * NEEDSDOC @param flushPrefixes * * @throws org.xml.sax.SAXException */ public final void flushPending(boolean flushPrefixes) throws org.xml.sax.SAXException { if (flushPrefixes && m_docPending) { flushDocEvent(); } if (m_elemIsPending) { // Combined loop shoud be much more efficient. // %REVIEW% %OPT% Will the "else" case ever arise? if (!m_nsDeclsHaveBeenAdded)// addNSDeclsToAttrs(); startAndAddPrefixMappings(); // new else // new sendStartPrefixMappings(); if (DEBUG) { System.out.println("ResultTreeHandler#flushPending - start flush: " + m_name); } flushElem(); if (DEBUG) { System.out.println( "ResultTreeHandler#flushPending - after flush, isPending: " + m_elemIsPending); } m_nsContextPushed = false; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?