You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mi...@apache.org on 2004/07/21 23:19:11 UTC
cvs commit: xml-xalan/java/src/org/apache/xml/serializer SerializerBase.java ToTextStream.java
minchau 2004/07/21 14:19:10
Modified: java/src/org/apache/xml/serializer SerializerBase.java
ToTextStream.java
Log:
PR: bugzilla 29706
Submitted by: Brian Minchau
Reviewed by: Christine Li
A fix to add a temporary vs. permanent output state to the serializer
(AKA result-tree-handler). In theory the XSLT processor should set the
temporary or permanent output state, but we observer that when the
encoding of a ToTextStream serializer is null, then such a serializer is
in temporary output state.
In temorary output state we don't do any escaping or encoding or other
sorts of normalization on output. This will be done by another serializer
later on, and that one will be in permanent output state.
Revision Changes Path
1.12 +19 -1 xml-xalan/java/src/org/apache/xml/serializer/SerializerBase.java
Index: SerializerBase.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/SerializerBase.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SerializerBase.java 1 Apr 2004 18:45:30 -0000 1.11
+++ SerializerBase.java 21 Jul 2004 21:19:10 -0000 1.12
@@ -1267,5 +1267,23 @@
// don't set writer to null, so that it might be re-used
//this.m_writer = null;
}
+
+ /**
+ * Returns true if the serializer is used for temporary output rather than
+ * final output.
+ *
+ * This concept is made clear in the XSLT 2.0 draft.
+ */
+ final boolean inTemporaryOutputState()
+ {
+ /* This is a hack. We should really be letting the serializer know
+ * that it is in temporary output state with an explicit call, but
+ * from a pragmatic point of view (for now anyways) having no output
+ * encoding at all, not even the default UTF-8 indicates that the serializer
+ * is being used for temporary RTF.
+ */
+ return (getEncoding() == null);
+
+ }
}
1.16 +20 -3 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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ToTextStream.java 17 Feb 2004 04:18:18 -0000 1.15
+++ ToTextStream.java 21 Jul 2004 21:19:10 -0000 1.16
@@ -191,12 +191,29 @@
throws org.xml.sax.SAXException
{
- // this.accum(ch, start, length);
flushPending();
try
{
- writeNormalizedChars(ch, start, length, false, m_lineSepUse);
+ if (inTemporaryOutputState()) {
+ /* leave characters un-processed as we are
+ * creating temporary output, the output generated by
+ * this serializer will be input to a final serializer
+ * later on and it will do the processing in final
+ * output state (not temporary output state).
+ *
+ * A "temporary" ToTextStream serializer is used to
+ * evaluate attribute value templates (for example),
+ * and the result of evaluating such a thing
+ * is fed into a final serializer later on.
+ */
+ m_writer.write(ch, start, length);
+ }
+ else {
+ // In final output state we do process the characters!
+ writeNormalizedChars(ch, start, length, false, m_lineSepUse);
+ }
+
if (m_tracer != null)
super.fireCharEvent(ch, start, length);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org