Greetings.
I am using Xalan 1.1 compiled on windows 2000 with VC6++ on a pentium 3,
compiled with the dinkumware fixes.
Problem:
1.We need to support french characaters such as ��� etc...
Synopsis:
I am having trouble with the XalanTransformer class, using stream input,
accepting ISO-8859-1 documents. However the code works fine when accepting
filenames.
Symptoms:
1.If we read from files, then there is no problem and the xalantransformer
takes iso-8859-1, handles the characters and provides correct output.
2.However once we read from streams, the xalantransformer returns the
following error:
XSL Warning: Fatal Error at (file idSysXML, line 1, column 732): Expected
comment or processing instruction
Which is invariably the end of the xml document. (note that this occurs when
iso-8859-1 is specified regardless or not if special characters such as ��
exist in the xml document.)
3.But I must stress that the same code will parse utf-8 encoded documents
without any problem.
I am at my wits end. Any advice would be helpful and appreciated.
here is an example of my code (with all the error handling removed for
simplicity) (sorry about the complexity, but a simple hello world xsl and
xml have the same result):
Format_Impl(const std::string& sXMLinput, const std::string& sXSLinput)
{
// Create the input stream with the XML document.
std::strstreambuf XmlBuffer(sXMLinput.c_str(),0);
std::istream XmlStream(&XmlBuffer);
// Create the input stream with the XSL document.
std::strstreambuf XslBuffer(sXSLinput.c_str(),0);
std::istream XslStream(&XslBuffer);
// Create a new output buffer.
std::strstreambuf* OutputBuffer;
OutputBuffer= new std::strstreambuf();
std::ostream OutputStream(OutputBuffer);
// This is it, Use the XalanTransformer to Parse the files.
XSLTInputSource isXML("idSysXML");
XSLTInputSource isXSL("idSysXSL");
XSLTResultTarget rtOut(&OutputStream);
isXML.setStream(&XmlStream);
isXSL.setStream(&XslStream);
XALANTRANSFORMER.transform(isXML,isXSL,rtOut); //xalan transformer
declared previously
std::string ReturnString;
OutputStream<<'\0';
ReturnString=OutputBuffer->str();
OutputBuffer->freeze(0);
OutputStream.flush();
delete OutputBuffer;
return ReturnString;
}
The XSL Document as follows:
"<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" />
<xsl:template match="MS_GET_SESSION_VAR">
<xsl:if test="@MS_VAR_NAME='USERNAME'">admin</xsl:if>
</xsl:template><xsl:template match="*"><xsl:copy><xsl:copy-of select="@*"/>
<xsl:apply-templates/></xsl:copy></xsl:template></xsl:stylesheet>");
The XML Document as follows:
"<?xml version="1.0" encoding="ISO-8859-1"?>
<MS_CONFIG_PAGE>
<MS_PROFILING>
<ConfiguratorTransaction>
<TransactionRequest>
<Request>
<CommandName>LIST_PROFILE</CommandName>
<MS_USR_ST_NAME><MS_GET_SESSION_VAR
MS_VAR_NAME="USERNAME"/></MS_USR_ST_NAME>
</Request>
</TransactionRequest>
</ConfiguratorTransaction>
</MS_PROFILING>
<MS_LAYOUT_TYPE>
<MS_LAYOUT_SNAME>Layout1</MS_LAYOUT_SNAME>
<MS_LAYOUT_DEVICE_NTYPE>0</MS_LAYOUT_DEVICE_NTYPE>
<MS_LAYOUT_SPATH>profile.xsl</MS_LAYOUT_SPATH>
</MS_LAYOUT_TYPE>
<MS_LANGUAGE_TYPE>
<MS_LANGUAGE_XML_SPATH>language-en.xml</MS_LANGUAGE_XML_SPATH>
<MS_LANGUAGE_ID>0</MS_LANGUAGE_ID>
<MS_LANGUAGE_SNAME>English</MS_LANGUAGE_SNAME>
</MS_LANGUAGE_TYPE>
<MS_LOGIN/>
</MS_CONFIG_PAGE>");
Thanks
Jason
______________________________________
Jason Jung, developer
Eurekium Innovations inc.
"Eurekium, the element of innovation."
email : [EMAIL PROTECTED]
tel. : 514.286.6966
fax : 514.286.6658
web : www.eurekium.com