< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/ToStream.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. --- 1,7 ---- /* ! * Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership.
*** 49,59 **** /** * This abstract class is a base class for other stream * serializers (xml, html, text ...) that write output to a stream. * * @xsl.usage internal ! * @LastModified: Sept 2018 */ abstract public class ToStream extends SerializerBase { private static final String COMMENT_BEGIN = "<!--"; private static final String COMMENT_END = "-->"; --- 49,59 ---- /** * This abstract class is a base class for other stream * serializers (xml, html, text ...) that write output to a stream. * * @xsl.usage internal ! * @LastModified: July 2019 */ abstract public class ToStream extends SerializerBase { private static final String COMMENT_BEGIN = "<!--"; private static final String COMMENT_END = "-->";
*** 1229,1239 **** { closeStartTag(); m_elemContext.m_startTagOpen = false; } ! if (!m_cdataTagOpen && shouldIndent()) indent(); boolean writeCDataBrackets = (((length >= 1) && escapingNotNeeded(ch[start]))); --- 1229,1239 ---- { closeStartTag(); m_elemContext.m_startTagOpen = false; } ! if (!m_cdataTagOpen && shouldIndentForText()) indent(); boolean writeCDataBrackets = (((length >= 1) && escapingNotNeeded(ch[start])));
*** 1268,1277 **** --- 1268,1278 ---- */ if (ch[start + length - 1] == ']') closeCDATA(); } + m_isprevtext = true; // time to fire off CDATA event if (m_tracer != null) super.fireCDATAEvent(ch, old_start, length); } catch (IOException ioe)
*** 1534,1548 **** throw new SAXException(e); } } /** ! * Used to flush the buffered characters when indentation is on, this method ! * will be called when the next node is traversed. * */ ! final protected void flushCharactersBuffer() throws SAXException { try { if (shouldFormatOutput() && m_charactersBuffer.isAnyCharactersBuffered()) { if (m_elemContext.m_isCdataSection) { /* * due to cdata-section-elements atribute, we need this as --- 1535,1551 ---- throw new SAXException(e); } } /** ! * Flushes the buffered characters when indentation is on. This method ! * is called before the next node is traversed. * + * @param isText indicates whether the node to be traversed is text + * @throws org.xml.sax.SAXException */ ! final protected void flushCharactersBuffer(boolean isText) throws SAXException { try { if (shouldFormatOutput() && m_charactersBuffer.isAnyCharactersBuffered()) { if (m_elemContext.m_isCdataSection) { /* * due to cdata-section-elements atribute, we need this as
*** 1551,1561 **** --- 1554,1566 ---- char[] chars = m_charactersBuffer.toChars(); cdata(chars, 0, chars.length); return; } + if (!isText) { m_childNodeNum++; + } boolean skipBeginningNewlines = false; if (shouldIndentForText()) { indent(); m_startNewLine = true; // newline has always been added here because if this is the
*** 1844,1854 **** if (isInEntityRef()) return; if (m_doIndent) { m_childNodeNum++; ! flushCharactersBuffer(); } if (m_needToCallStartDocument) { startDocumentInternal(); --- 1849,1859 ---- if (isInEntityRef()) return; if (m_doIndent) { m_childNodeNum++; ! flushCharactersBuffer(false); } if (m_needToCallStartDocument) { startDocumentInternal();
*** 2115,2125 **** if (isInEntityRef()) return; if (m_doIndent) { ! flushCharactersBuffer(); } // namespaces declared at the current depth are no longer valid // so get rid of them m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth, null); --- 2120,2130 ---- if (isInEntityRef()) return; if (m_doIndent) { ! flushCharactersBuffer(false); } // namespaces declared at the current depth are no longer valid // so get rid of them m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth, null);
*** 2307,2317 **** int start_old = start; if (isInEntityRef()) return; if (m_doIndent) { m_childNodeNum++; ! flushCharactersBuffer(); } if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false; --- 2312,2322 ---- int start_old = start; if (isInEntityRef()) return; if (m_doIndent) { m_childNodeNum++; ! flushCharactersBuffer(false); } if (m_elemContext.m_startTagOpen) { closeStartTag(); m_elemContext.m_startTagOpen = false;
*** 2489,2500 **** * @see #endCDATA */ public void startCDATA() throws org.xml.sax.SAXException { if (m_doIndent) { ! m_childNodeNum++; ! flushCharactersBuffer(); } m_cdataStartCalled = true; } --- 2494,2504 ---- * @see #endCDATA */ public void startCDATA() throws org.xml.sax.SAXException { if (m_doIndent) { ! flushCharactersBuffer(true); } m_cdataStartCalled = true; }
< prev index next >