Return-Path: Delivered-To: apmail-xml-xalan-cvs-archive@xml.apache.org Received: (qmail 20974 invoked by uid 500); 7 Jul 2003 06:23:54 -0000 Mailing-List: contact xalan-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: Delivered-To: mailing list xalan-cvs@xml.apache.org Received: (qmail 20880 invoked from network); 7 Jul 2003 06:23:53 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 7 Jul 2003 06:23:53 -0000 Received: (qmail 16452 invoked by uid 1663); 7 Jul 2003 06:23:52 -0000 Date: 7 Jul 2003 06:23:52 -0000 Message-ID: <20030707062352.16451.qmail@icarus.apache.org> From: minchau@apache.org To: xml-xalan-cvs@apache.org Subject: cvs commit: xml-xalan/java/src/org/apache/xml/serializer ToXMLSAXHandler.java ToHTMLStream.java ToStream.java NamespaceMappings.java ToTextStream.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N minchau 2003/07/06 23:23:52 Modified: java/src/org/apache/xml/serializer ToXMLSAXHandler.java ToHTMLStream.java ToStream.java NamespaceMappings.java ToTextStream.java Log: Patches for bugzilla 20841 and 21039. PR: 20841, 21039 Submitted by: Brian Minchau Revision Changes Path 1.8 +2 -1 xml-xalan/java/src/org/apache/xml/serializer/ToXMLSAXHandler.java Index: ToXMLSAXHandler.java =================================================================== RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToXMLSAXHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ToXMLSAXHandler.java 25 Jun 2003 17:05:02 -0000 1.7 +++ ToXMLSAXHandler.java 7 Jul 2003 06:23:51 -0000 1.8 @@ -295,7 +295,8 @@ /* Pop all namespaces at the current element depth. * We are not waiting for official endPrefixMapping() calls. */ - m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth); + m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth, + m_saxHandler); m_elemContext = m_elemContext.m_prev; } 1.19 +2 -2 xml-xalan/java/src/org/apache/xml/serializer/ToHTMLStream.java Index: ToHTMLStream.java =================================================================== RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToHTMLStream.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ToHTMLStream.java 25 Jun 2003 17:05:02 -0000 1.18 +++ ToHTMLStream.java 7 Jul 2003 06:23:51 -0000 1.19 @@ -1434,7 +1434,7 @@ // writer.write(""); @@ -1509,7 +1509,7 @@ indent(); // writer.write(ch, start, length); - writeNormalizedChars(ch, start, length, true); + writeNormalizedChars(ch, start, length, true, m_lineSepUse); } catch (IOException ioe) { 1.16 +34 -6 xml-xalan/java/src/org/apache/xml/serializer/ToStream.java Index: ToStream.java =================================================================== RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToStream.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ToStream.java 25 Jun 2003 17:05:03 -0000 1.15 +++ ToStream.java 7 Jul 2003 06:23:51 -0000 1.16 @@ -152,10 +152,15 @@ protected int m_maxCharacter = Encodings.getLastPrintable(); /** - * Use the system line seperator to write line breaks. + * The system line separator for writing out line breaks. */ protected final char[] m_lineSep = System.getProperty("line.separator").toCharArray(); + + /** + * True if the the system line separator is to be used. + */ + protected boolean m_lineSepUse = true; /** * The length of the line seperator, since the write is done @@ -701,6 +706,25 @@ else m_writer = writer; } + + /** + * Set if the operating systems end-of-line line separator should + * be used when serializing. If set false NL character + * (decimal 10) is left alone, otherwise the new-line will be replaced on + * output with the systems line separator. For example on UNIX this is + * NL, while on Windows it is two characters, CR NL, where CR is the + * carriage-return (decimal 13). + * + * @param use_sytem_line_break True if an input NL is replaced with the + * operating systems end-of-line separator. + * @return The previously set value of the serializer. + */ + public boolean setLineSepUse(boolean use_sytem_line_break) + { + boolean oldValue = m_lineSepUse; + m_lineSepUse = use_sytem_line_break; + return oldValue; + } /** * Specifies an output stream to which the document should be @@ -1083,6 +1107,8 @@ * @param start The start position in the array. * @param length The number of characters to read from the array. * @param isCData true if a CDATA block should be built around the characters. + * @param useSystemLineSeparator true if the operating systems + * end-of-line separator should be output rather than a new-line character. * * @throws IOException * @throws org.xml.sax.SAXException @@ -1091,7 +1117,8 @@ char ch[], int start, int length, - boolean isCData) + boolean isCData, + boolean useSystemLineSeparator) throws IOException, org.xml.sax.SAXException { final java.io.Writer writer = m_writer; @@ -1101,7 +1128,7 @@ { char c = ch[i]; - if (CharInfo.S_LINEFEED == c) + if (CharInfo.S_LINEFEED == c && useSystemLineSeparator) { writer.write(m_lineSep, 0, m_lineSepLen); } @@ -1269,7 +1296,7 @@ charactersRaw(ch, start, length); } else - writeNormalizedChars(ch, start, length, true); + writeNormalizedChars(ch, start, length, true, m_lineSepUse); /* used to always write out CDATA closing delimiter here, * but now we delay, so that we can merge CDATA sections on output. @@ -1432,7 +1459,7 @@ for (i = start; ((i < end) && ((ch1 = chars[i]) == 0x20 - || ch1 == 0xA + || (ch1 == 0xA && m_lineSepUse) || ch1 == 0xD || ch1 == 0x09)); i++) @@ -1960,7 +1987,7 @@ // namespaces declared at the current depth are no longer valid // so get rid of them - m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth); + m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth, null); try { @@ -2900,6 +2927,7 @@ this.m_spaceBeforeClose = false; this.m_startNewLine = false; this.m_triedToGetConverter = false; + this.m_lineSepUse = true; // DON'T SET THE WRITER TO NULL, IT MAY BE REUSED !! // this.m_writer = null; 1.3 +20 -2 xml-xalan/java/src/org/apache/xml/serializer/NamespaceMappings.java Index: NamespaceMappings.java =================================================================== RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/NamespaceMappings.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NamespaceMappings.java 28 May 2003 15:11:14 -0000 1.2 +++ NamespaceMappings.java 7 Jul 2003 06:23:51 -0000 1.3 @@ -59,6 +59,9 @@ import java.util.Hashtable; import java.util.Stack; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + /** * This class keeps track of the currently defined namespaces. Conceptually the * prefix/uri/depth triplets are pushed on a stack pushed on a stack. The depth @@ -255,8 +258,10 @@ * declared at the given element depth, or deepter. * @param elemDepth the element depth for which mappings declared at this * depth or deeper will no longer be valid + * @param saxHandler The ContentHandler to notify of any endPrefixMapping() + * calls. This parameter can be null. */ - public void popNamespaces(int elemDepth) + public void popNamespaces(int elemDepth, ContentHandler saxHandler) { while (true) { @@ -270,7 +275,20 @@ */ m_nodeStack.pop(); - popNamespace((String) m_prefixStack.pop()); + final String prefix = (String) m_prefixStack.pop(); + popNamespace(prefix); + if (saxHandler != null) + { + try + { + saxHandler.endPrefixMapping(prefix); + } + catch (SAXException e) + { + // not much we can do if they aren't willing to listen + } + } + } } 1.10 +11 -8 xml-xalan/java/src/org/apache/xml/serializer/ToTextStream.java Index: ToTextStream.java =================================================================== RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/ToTextStream.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ToTextStream.java 25 Jun 2003 17:05:02 -0000 1.9 +++ ToTextStream.java 7 Jul 2003 06:23:51 -0000 1.10 @@ -233,7 +233,7 @@ try { - writeNormalizedChars(ch, start, length, false); + writeNormalizedChars(ch, start, length, false, m_lineSepUse); if (m_tracer != null) super.fireCharEvent(ch, start, length); } @@ -260,7 +260,7 @@ try { - writeNormalizedChars(ch, start, length, false); + writeNormalizedChars(ch, start, length, false, m_lineSepUse); } catch(IOException ioe) { @@ -277,7 +277,9 @@ * @param start The start position in the array. * @param length The number of characters to read from the array. * @param isCData true if a CDATA block should be built around the characters. - * + * @param useLineSep true if the operating systems + * end-of-line separator should be output rather than a new-line character. + * * @throws IOException * @throws org.xml.sax.SAXException */ @@ -285,7 +287,8 @@ final char ch[], final int start, final int length, - final boolean isCData) + final boolean isCData, + final boolean useLineSep) throws IOException, org.xml.sax.SAXException { final java.io.Writer writer = m_writer; @@ -301,7 +304,7 @@ { final char c = ch[i]; - if (S_LINEFEED == c) + if (S_LINEFEED == c && useLineSep) { writer.write(m_lineSep, 0, m_lineSepLen); } @@ -360,7 +363,7 @@ { final char c = ch[i]; - if (S_LINEFEED == c) + if (S_LINEFEED == c && useLineSep) { writer.write(m_lineSep, 0, m_lineSepLen); } @@ -410,7 +413,7 @@ { try { - writeNormalizedChars(ch, start, length, false); + writeNormalizedChars(ch, start, length, false, m_lineSepUse); if (m_tracer != null) super.fireCDATAEvent(ch, start, length); } @@ -452,7 +455,7 @@ try { - writeNormalizedChars(ch, start, length, false); + writeNormalizedChars(ch, start, length, false, m_lineSepUse); } catch(IOException ioe) { --------------------------------------------------------------------- To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: xalan-cvs-help@xml.apache.org