You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@locus.apache.org on 2000/05/24 21:26:16 UTC

cvs commit: xml-xalan/c/src/XMLSupport FormatterToXML.cpp FormatterToXML.hpp

dbertoni    00/05/24 12:26:14

  Modified:    c/src/XMLSupport FormatterToXML.cpp FormatterToXML.hpp
  Log:
  Fix for normalizing PI data.
  
  Revision  Changes    Path
  1.19      +32 -3     xml-xalan/c/src/XMLSupport/FormatterToXML.cpp
  
  Index: FormatterToXML.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToXML.cpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- FormatterToXML.cpp	2000/05/18 18:37:23	1.18
  +++ FormatterToXML.cpp	2000/05/24 19:26:12	1.19
  @@ -71,7 +71,7 @@
   
   
   
  -static XalanDOMChar 		theDefaultAttrSpecialChars[] = {'<', '>', '&', '"', '\r', '\n' };
  +static const XalanDOMChar 	theDefaultAttrSpecialChars[] = {'<', '>', '&', '"', '\r', '\n', 0 };
   
   
   const XalanDOMCharVectorType	FormatterToXML::s_xsltNextIsRawString =
  @@ -805,12 +805,14 @@
   			accum('?');
   			accum(target);
   
  -			if (length(data) > 0 && !isSpace(data[0]))
  +			const unsigned int	len = length(data);
  +
  +			if ( len > 0 && !isSpace(data[0]))
   			{
   				accum(' ');
   			}
   
  -			accum(data);
  +			accumNormalizedPIData(data, len);
   
   			accum('?');
   			accum('>');
  @@ -1241,6 +1243,33 @@
   	if(m_doIndent == true)
   	{
   		printSpace(n);
  +	}
  +}
  +
  +
  +
  +void
  +FormatterToXML::accumNormalizedPIData(
  +			const XalanDOMChar*		theData,
  +			unsigned int			theLength)
  +{
  +	// If there are any "?>" pairs in the string,
  +	// we have to normalize them to "? >", so they
  +	// won't be confused with the end tag.
  +
  +	for (unsigned int i = 0; i < theLength; ++i)
  +	{
  +		const XalanDOMChar	theChar = theData[i];
  +
  +		if (theChar == '?' && i + 1 < theLength && theData[i + 1] == '>')
  +		{
  +			accum('?');
  +			accum(' ');
  +		}
  +		else
  +		{
  +			accum(theChar);
  +		}
   	}
   }
   
  
  
  
  1.12      +18 -3     xml-xalan/c/src/XMLSupport/FormatterToXML.hpp
  
  Index: FormatterToXML.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XMLSupport/FormatterToXML.hpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FormatterToXML.hpp	2000/05/18 18:37:23	1.11
  +++ FormatterToXML.hpp	2000/05/24 19:26:12	1.12
  @@ -67,7 +67,6 @@
   
   #include <stack>
   #include <vector>
  -//#include <map>
   
   
   
  @@ -96,6 +95,11 @@
   {
   public:
   
  +	enum eDummy
  +	{
  +		eDefaultIndentAmount = 4
  +	};
  +
   	/**
   	 * Constructor for customized encoding and doctype.
   	 *
  @@ -120,7 +124,7 @@
   			Writer&					writer,
   			const XalanDOMString&	version = XalanDOMString(),
   			bool					doIndent = false,
  -			int						indent = 0,
  +			int						indent = eDefaultIndentAmount,
   			const XalanDOMString&	encoding = XalanDOMString(),
   			const XalanDOMString&	mediaType = XalanDOMString(),
   			const XalanDOMString&	doctypeSystem = XalanDOMString(),
  @@ -499,7 +503,7 @@
   			XalanDOMChar	ch,
   			unsigned int	next);
   
  -	enum eDummy { SPECIALSSIZE = 256};
  +	enum eDummyTwo { SPECIALSSIZE = 256};
   
   	/**
   	 * The maximum character size before we have to resort 
  @@ -668,6 +672,17 @@
   			accum(' ');
   		}
   	}
  +
  +	/**
  +	 * Normalize the data in a PI, to replace any
  +	 * "?>" pairs with "? >"
  +	 * @param theData the data to normalize.
  +	 */
  +	void
  +	accumNormalizedPIData(
  +			const XalanDOMChar*		theData,
  +			unsigned int			theLength);
  +
   
   	// Data members...
   	bool		m_shouldFlush;