dbertoni 2002/12/11 14:51:41
Modified: c/src/XSLT StylesheetRoot.cpp StylesheetRoot.hpp
Log:
Don't honor cdata-section-elements for HTML output. Make sure we honor the
encoding the XSLTResultTarget instance. Fixed bugzilla 13284.
Revision Changes Path
1.71 +45 -17 xml-xalan/c/src/XSLT/StylesheetRoot.cpp
Index: StylesheetRoot.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- StylesheetRoot.cpp 25 Nov 2002 18:11:53 -0000 1.70
+++ StylesheetRoot.cpp 11 Dec 2002 22:51:40 -0000 1.71
@@ -177,7 +177,12 @@
m_needToBuildKeysTable = true;
}
- if (m_cdataSectionElems.size() > 0)
+ // cdata-section-elements only applies to the XML output method...
+ if (m_outputMethod != FormatterListener::OUTPUT_METHOD_XML)
+ {
+ m_cdataSectionElems.clear();
+ }
+ else if (m_cdataSectionElems.size() > 0)
{
XALAN_USING_STD(sort)
@@ -270,6 +275,23 @@
+const XalanDOMString&
+StylesheetRoot::getEncoding(const XSLTResultTarget& outputTarget)
const
+{
+ const XalanDOMString& theEncoding = outputTarget.getEncoding();
+
+ if (theEncoding.length() != 0)
+ {
+ return theEncoding;
+ }
+ else
+ {
+ return m_encoding;
+ }
+}
+
+
+
FormatterListener*
StylesheetRoot::setupFormatterListener(
XSLTResultTarget&
outputTarget,
@@ -331,6 +353,8 @@
const bool doIndent = (indentAmount > -1) ? true :
m_indentResult;
+ const XalanDOMString& theEncoding = getEncoding(outputTarget);
+
switch(m_outputMethod)
{
case FormatterListener::OUTPUT_METHOD_HTML:
@@ -380,7 +404,7 @@
flistener =
executionContext.createFormatterToHTML(
*pw,
- m_encoding,
+ theEncoding,
m_mediatype,
m_doctypeSystem,
m_doctypePublic,
@@ -392,7 +416,7 @@
break;
case FormatterListener::OUTPUT_METHOD_TEXT:
- flistener = executionContext.createFormatterToText(*pw,
m_encoding);
+ flistener = executionContext.createFormatterToText(*pw,
theEncoding);
break;
case FormatterListener::OUTPUT_METHOD_NONE:
@@ -406,7 +430,7 @@
}
flistener = executionContext.createFormatterToXML(
- *pw, m_version, doIndent,
indentAmount, m_encoding, m_mediatype,
+ *pw, m_version, doIndent,
indentAmount, theEncoding, m_mediatype,
m_doctypeSystem,
m_doctypePublic, !m_omitxmlDecl, m_standalone);
break;
}
@@ -538,26 +562,30 @@
}
else
if(equals(aname,Constants::ATTRNAME_OUTPUT_CDATA_SECTION_ELEMENTS))
{
- StringTokenizer theTokenizer(atts.getValue(i));
+ if (m_outputMethod ==
FormatterListener::OUTPUT_METHOD_NONE ||
+ m_outputMethod ==
FormatterListener::OUTPUT_METHOD_XML)
+ {
+ StringTokenizer theTokenizer(atts.getValue(i));
- StringTokenizer::size_type theTokenCount =
- theTokenizer.countTokens();
+ StringTokenizer::size_type theTokenCount =
+ theTokenizer.countTokens();
- m_cdataSectionElems.reserve(m_cdataSectionElems.size()
+ theTokenCount);
+
m_cdataSectionElems.reserve(m_cdataSectionElems.size() + theTokenCount);
- XalanDOMString theToken;
+ XalanDOMString theToken;
- while(theTokenCount > 0)
- {
- theTokenizer.nextToken(theToken);
+ while(theTokenCount > 0)
+ {
+ theTokenizer.nextToken(theToken);
- --theTokenCount;
+ --theTokenCount;
- m_cdataSectionElems.push_back(
-
constructionContext.createXalanQName(theToken, getNamespaces(), theLocator,
true));
- }
+ m_cdataSectionElems.push_back(
+
constructionContext.createXalanQName(theToken, getNamespaces(), theLocator,
true));
+ }
- assert(theTokenizer.hasMoreTokens() == false);
+ assert(theTokenizer.hasMoreTokens() == false);
+ }
}
else
{
1.26 +12 -2 xml-xalan/c/src/XSLT/StylesheetRoot.hpp
Index: StylesheetRoot.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.hpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- StylesheetRoot.hpp 25 Nov 2002 18:11:53 -0000 1.25
+++ StylesheetRoot.hpp 11 Dec 2002 22:51:41 -0000 1.26
@@ -125,8 +125,8 @@
/**
* Transform the source tree to the output in the given result tree
target.
*
- * @param inputSource The input source tree
- * @param outputTarget The output source tree
+ * @param inputSource The input source
+ * @param outputTarget The output result target
* @param constructionContext context for construction of object
*/
void
@@ -434,6 +434,16 @@
const XalanText&
textNode) const;
private:
+
+ /**
+ * Choose the encoding to use.
+ *
+ * @param outputTarget The output result target
+ *
+ * @return The chosen encoding
+ */
+ const XalanDOMString&
+ getEncoding(const XSLTResultTarget& outputTarget) const;
/**
* Create the default rule if needed.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]