/** * If this method is called, the serializer is used as a * DTDHandler, which changes behavior how the serializer * handles document entities. * @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String) */ public void notationDecl(String name, String pubID, String sysID) throws SAXException { // TODO Auto-generated method stub try { DTDprolog(); m_writer.write("<!NOTATION "); m_writer.write(name); if (pubID != null) { m_writer.write(" PUBLIC \""); m_writer.write(pubID); } else { m_writer.write(" SYSTEM \""); m_writer.write(sysID); } m_writer.write("\" >"); m_writer.write(m_lineSep, 0, m_lineSepLen); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
int pos = accumDefaultEntity(writer, ch, i, chars, len, fromTextNode, escLF); if (isCharacterInC0orC1Range(ch) || isNELorLSEPCharacter(ch)) writer.write(';'); else if ((!escapingNotNeeded(ch) || ( (fromTextNode && m_charInfo.shouldMapTextChar(ch)) || (!fromTextNode && m_charInfo.shouldMapAttrChar(ch))))
accumDefaultEscape( m_writer, (char)ch,
/** * This method flushes any pending events, which can be startDocument() * closing the opening tag of an element, or closing an open CDATA section. */ public void flushPending() throws SAXException { if (m_needToCallStartDocument) { startDocumentInternal(); m_needToCallStartDocument = false; } if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; } if (m_cdataTagOpen) { closeCDATA(); m_cdataTagOpen = false; } if (m_writer != null) { try { m_writer.flush(); } catch(IOException e) { // what? me worry? } } }
/** * Report the beginning of an entity. * * The start and end of the document entity are not reported. * The start and end of the external DTD subset are reported * using the pseudo-name "[dtd]". All other events must be * properly nested within start/end entity events. * * @param name The name of the entity. If it is a parameter * entity, the name will begin with '%'. * @throws org.xml.sax.SAXException The application may raise an exception. * @see #endEntity * @see org.xml.sax.ext.DeclHandler#internalEntityDecl * @see org.xml.sax.ext.DeclHandler#externalEntityDecl */ public void startEntity(String name) throws org.xml.sax.SAXException { if (name.equals("[dtd]")) m_inExternalDTD = true; if (!m_expandDTDEntities && !m_inExternalDTD) { /* Only leave the entity as-is if * we've been told not to expand them * and this is not the magic [dtd] name. */ startNonEscaping(); characters("&" + name + ';'); endNonEscaping(); } m_inEntityRef = true; }
/** * Report an internal entity declaration. * * <p>Only the effective (first) declaration for each entity * will be reported.</p> * * @param name The name of the entity. If it is a parameter * entity, the name will begin with '%'. * @param value The replacement text of the entity. * @exception SAXException The application may raise an exception. * @see #externalEntityDecl * @see org.xml.sax.DTDHandler#unparsedEntityDecl */ public void internalEntityDecl(String name, String value) throws SAXException { // Do not inline external DTD if (m_inExternalDTD) return; try { DTDprolog(); outputEntityDecl(name, value); } catch (IOException e) { throw new SAXException(e); } }
char first = getFirstCharLocName(name); switch (first) { case 'c': if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name)) { String cdataSectionNames = val; addCdataSectionElements(cdataSectionNames); final String oldExplicitEncoding = getOutputPropertyNonDefault(OutputKeys.ENCODING); final String oldDefaultEncoding = getOutputPropertyDefault(OutputKeys.ENCODING); if ( (defaultVal && ( oldDefaultEncoding == null || !oldDefaultEncoding.equalsIgnoreCase(newEncoding))) || ( !defaultVal && (oldExplicitEncoding == null || !oldExplicitEncoding.equalsIgnoreCase(newEncoding) ))) { OutputStream os = getOutputStream(); if (os != null) { Writer w = getWriter(); String oldEncoding = getOutputProperty(OutputKeys.ENCODING); if ((w == null || !m_writer_set_by_user) && !newEncoding.equalsIgnoreCase(oldEncoding)) { setOutputStreamInternal(os,false); case 'i': if (OutputPropertiesFactory.S_KEY_INDENT_AMOUNT.equals(name)) { setIndentAmount(Integer.parseInt(val)); } else if (OutputKeys.INDENT.equals(name)) { boolean b = "yes".equals(val) ? true : false; setStandaloneInternal(val);
if (m_elemContext.m_startTagOpen) closeStartTag(); m_elemContext.m_startTagOpen = false; if (shouldIndent()) indent(); (((length >= 1) && escapingNotNeeded(ch[start]))); if (isEscapingDisabled()) charactersRaw(ch, start, length); writeNormalizedChars(ch, start, length, true, m_lineSepUse); closeCDATA();
startDocumentInternal(); m_needToCallStartDocument = false; m_docIsEmpty = false; closeCDATA(); try if(null != getDoctypeSystem()) { outputDocTypeDecl(name, true); closeStartTag(); m_elemContext.m_startTagOpen = false; ensurePrefixIsDeclared(namespaceURI, name); if (shouldIndent() && m_startNewLine) indent(); addAttributes(atts); firePseudoAttributes();
closeStartTag(); m_elemContext.m_startTagOpen = false; startDocumentInternal(); cdata(chars, start, length); closeCDATA(); charactersRaw(chars, start, length); closeStartTag(); m_elemContext.m_startTagOpen = false; writeOutCleanChars(chars, i, lastDirtyCharProcessed); String outputStringForChar = m_charInfo .getOutputStringForChar(ch1); break; case CharInfo.S_LINEFEED: lastDirtyCharProcessed = processLineFeed(chars, i, lastDirtyCharProcessed, writer); i++; break; case CharInfo.S_CARRIAGERETURN: writeOutCleanChars(chars, i, lastDirtyCharProcessed); writer.write(" "); lastDirtyCharProcessed = i;
if (OutputKeys.CDATA_SECTION_ELEMENTS.equals(name)) { String cdataSectionNames = val; addCdataSectionElements(cdataSectionNames); OutputStream os = getOutputStream(); if (os != null) { Writer w = getWriter(); setOutputStreamInternal(os,false); case 'i': if (OutputPropertiesFactory.S_KEY_INDENT_AMOUNT.equals(name)) { setIndentAmount(Integer.parseInt(val)); } else if (OutputKeys.INDENT.equals(name)) { boolean b = "yes".equals(val) ? true : false;
addCdataSectionElement(buf.toString(), v); buf.setLength(0); addCdataSectionElement(buf.toString(), v); buf.setLength(0); setCdataSectionElements(v);
if (m_elemContext.m_startTagOpen) closeStartTag(); m_elemContext.m_startTagOpen = false; startDocumentInternal(); m_needToCallStartDocument = false; boolean wasDash = false; if (m_cdataTagOpen) closeCDATA(); if (shouldIndent()) indent();
void ensurePrefixIsDeclared(String ns, String rawName) throws org.xml.sax.SAXException { if (ns != null && ns.length() > 0) { int index; final boolean no_prefix = ((index = rawName.indexOf(":")) < 0); String prefix = (no_prefix) ? "" : rawName.substring(0, index); if (null != prefix) { String foundURI = m_prefixMap.lookupNamespace(prefix); if ((null == foundURI) || !foundURI.equals(ns)) { this.startPrefixMapping(prefix, ns); // Bugzilla1133: Generate attribute as well as namespace event. // SAX does expect both. this.addAttributeAlways( "http://www.w3.org/2000/xmlns/", no_prefix ? "xmlns" : prefix, // local name no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname "CDATA", ns, false); } } } }
if (shouldIndent()) indent(); writeNormalizedChars(ch, start, length, true, m_lineSepUse); super.cdata(ch, start, length);
if (nAttrs > 0) processAttributes(m_writer, nAttrs); closeCDATA(); if (shouldIndent()) indent(m_elemContext.m_currentElemDepth - 1); writer.write('<'); writer.write('/');
else if (isCData && (!escapingNotNeeded(c))) closeCDATA(); writeUTF16Surrogate(c, ch, i, end); if (escapingNotNeeded(c)) closeCDATA(); writeUTF16Surrogate(c, ch, i, end); closeCDATA(); writer.write("&#");
closeCDATA(); try writer.write(name); String doctypePublic = getDoctypePublic(); if (null != doctypePublic) String doctypeSystem = getDoctypeSystem(); if (null != doctypeSystem)
/** * Receive notification of ignorable whitespace in element content. * * Not sure how to get this invoked quite yet. * * @param ch The characters from the XML document. * @param start The start position in the array. * @param length The number of characters to read from the array. * @throws org.xml.sax.SAXException Any SAX exception, possibly * wrapping another exception. * @see #characters * * @throws org.xml.sax.SAXException */ public void ignorableWhitespace(char ch[], int start, int length) throws org.xml.sax.SAXException { if (0 == length) return; characters(ch, start, length); }
super.cdata(ch, start, length);