Hello,
I have this problem. When I try to "process" a XML with a XSL I get the
following error message:
Fatal Error at (file , line 1, char1747): Expected comment or processing
instruction
Bellow is the C++ code and the XML text. I believe the problem comes
from the XML, I use strange ascii characters like � � � � � �. They are
<alt> + 160 = �, <alt> + 130 = �, <alt> + 161 = �, <alt> + 162 = �,
<alt> + 163 = �, <alt> + 164 = � (ascii codes are 160, 130, 161, 162,
163, 164). This are spanish characters. The XSL file is well formed. I
have test this XML with the XSL with the utility "testxslt" and it work.
But when I try to use it in a C++ program (in a Unix Sun Solaris 2.6) I
get the error I commented before.
When I call the function "call_xslt_processor" (see the code below), in
the first parameter I pass a "char *" pointing to a buffer where is the
XML. In the second parameter I pass the XSL file name. To make this
function I follow the examples shows in the documentation of Xalan-C++.
If you can help me, please tell how I can I make it work.
Thanks in advance.
Julio
--------------0----------------
void TranslatorApp::call_xslt_processor(char* r_Buffer, const char*
a_XSLFileName)
{
// Variables necesarias para el formatter.
const XalanDOMString mimeEncoding(XALAN_STATIC_UCODE_STRING("UTF-8"));
const StylesheetRoot* stylesheet = 0;
int type_output = FormatterListener::OUTPUT_METHOD_NONE;
bool writeXMLheader = true;
string bufftype;
// Armamos el istream que necesita el XSL Processor como input a partir
del buffer del mensaje.
strstreambuf mybuff(r_Buffer, strlen(r_Buffer));
istream mystream(&mybuff);
try {
// Initialize the Xalan XSLT subsystem...
XSLTInit theInit;
// Create the support objects that are necessary for running the
processor...
XercesDOMSupport theDOMSupport;
XercesParserLiaison
theParserLiaison(theDOMSupport);
XPathSupportDefault
theXPathSupport(theDOMSupport);
XSLTProcessorEnvSupportDefault
theXSLTProcessorEnvSupport;
XObjectFactoryDefault theXObjectFactory;
XPathFactoryDefault theXPathFactory;
// Create a processor...
XSLTEngineImpl theProcessor(
theParserLiaison,
theXPathSupport,
theXSLTProcessorEnvSupport,
theDOMSupport,
theXObjectFactory,
theXPathFactory);
// Connect the processor to the support object...
theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
// Create a stylesheet construction context, and a stylesheet
// execution context...
StylesheetConstructionContextDefault theConstructionContext(
theProcessor,
theXSLTProcessorEnvSupport,
theXPathFactory);
StylesheetExecutionContextDefault theExecutionContext(
theProcessor,
theXSLTProcessorEnvSupport,
theXPathSupport,
theXObjectFactory);
// Our input sources...
XSLTInputSource theInputSource(&mystream);
XSLTInputSource theStylesheetSource(a_XSLFileName);
// Our output target...
DOMStringPrintWriter myStringWriter;
XSLTResultTarget theResultTarget(&myStringWriter);
// Seteo los parametros para darle formato a la salida
if ( m_typeout != FORMAT_PLAIN_TEXT )
{
if (OPTION_EXISTS(PARAM_TYPE_OUT))
{
bufftype = GET_OPTION_VALUE(PARAM_TYPE_OUT);
type_output = getTypeFormat((char *)bufftype.c_str());
}
}
else
type_output = getTypeFormat("TEXT");
if ( type_output == FormatterListener::OUTPUT_METHOD_XML )
writeXMLheader = false;
stylesheet = theProcessor.processStylesheet(a_XSLFileName,
theConstructionContext);
// Instancio un Formatter, para definir el formato de la salida
const XalanAutoPtr<FormatterListener> formatter(
createFormatter(
// Tipo de Salida
type_output,
// Escribo el header de XML
writeXMLheader,
// params.stripCData,
false,
// params.escapeCData,
false,
myStringWriter,
theParserLiaison.getIndent(),
mimeEncoding,
stylesheet,
theParserLiaison)
);
if(formatter.get() != 0)
theResultTarget.setFormatterListener(formatter.get());
// Fin del formato de la salida
theProcessor.process(
theInputSource,
theStylesheetSource,
theResultTarget,
theConstructionContext,
theExecutionContext);
// Copiamos el resultado del procesamiento al buffer.
copy_string(r_Buffer, myStringWriter.getString());
}
catch(XSLProcessorException& e) {
string e_to_throw;
copy_string(e_to_throw, e.getMessage());
throw e_to_throw;
}
catch(XSLException& e) {
string e_to_throw;
copy_string(e_to_throw, XalanDOMString(e.getMessage()));
throw e_to_throw;
}
catch(XMLException& e) {
string e_to_throw;
copy_string(e_to_throw, XalanDOMString(e.getMessage()));
throw e_to_throw;
}
catch(...) {
throw string("Unknown Error aplying stylesheet");
}
}
---------0----------
<?xml version="1.0"
encoding="iso-8859-1"?><RIOCELULAR><CONSULTAS><FECHA_ACTUAL><DIA>01</DIA><MES>01</MES><ANO>2002</ANO><HORA>08:36</HORA></FECHA_ACTUAL><USUARIO><TIPO_ID>XXXXXXXX</TIPO_ID><ID_USUARIO>00013213101</ID_USUARIO><NOMBRE>XXXXXXXX</NOMBRE><APELLIDO>XXXXXXXX</APELLIDO><NUP>02299401</NUP></USUARIO><LINKSRCIMG>0</LINKSRCIMG><FORMATO_SALIDA>0</FORMATO_SALIDA><SERVICIOS><DEBITO_DIRECTO><PRIMERA_FACTURA>N</PRIMERA_FACTURA><ID_ADHESION>1234567890123456789012</ID_ADHESION><ID_DEBITO>123456789012345</ID_DEBITO><TIPO_MENSAJE><TIPO_REGISTRO>1</TIPO_REGISTRO><ESTADO>1</ESTADO><CODIGO_RECHAZO>R02
</CODIGO_RECHAZO><DES_RECHAZO>� � � � � Los datos de Su Cuenta tienen
inconvenientes para realizar el debito correspondiente al pago de este
servicio.</DES_RECHAZO><CALLTOACTION>Por favor acerquese a su sucursal
para verificar los datos de Su Cuenta y asi poder continuar con los
beneficios de abonar sus servicios por debito automatico en Su Cuenta. �
� � � �</CALLTOACTION></TIPO_MENSAJE><INFO_SERVICIO><ID_EMPRESA>EMPRESA
ZAPALLO</ID_EMPRESA><CUIT>12345678901</CUIT><SERVICIO>1234567890</SERVICIO></INFO_SERVICIO><PAGO><MONEDA>Ars</MONEDA><MONTO>852,36</MONTO><FECHA_VENCIMIENTO><ANO>2001</ANO><MES>09</MES><DIA>20</DIA></FECHA_VENCIMIENTO></PAGO><PAGO_TARJETA><ID>9876</ID><MONEDA>U$s</MONEDA><MONTO>369,01</MONTO><PAGO_MINIMO><MONEDA>Ars</MONEDA><MONTO>369,85</MONTO></PAGO_MINIMO><SALDO_CIERRE_PESOS><MONEDA>Ars</MONEDA><MONTO>690,14</MONTO><SIGNO>+</SIGNO></SALDO_CIERRE_PESOS><SALDO_CIERRE_DOLARES><MONEDA>U$s</MONEDA><MONTO>901,47</MONTO><SIGNO>+</SIGNO></SALDO_CIERRE_DOLARES></PAGO_TARJETA><CUENTA><TIPO_APLIC>1234</TIPO_APLIC><SUCURSAL>1234</SUCURSAL><TIPO>12</TIPO><NRO_CUENTA>444444444444</NRO_CUENTA><SALDO><MONEDA>Ars</MONEDA><MONTO>523,69</MONTO><SIGNO>+</SIGNO></SALDO><LIMITE>236,90</LIMITE></CUENTA><FECHA_GENERACION><ANO>2001</ANO><MES>09</MES><DIA>20</DIA></FECHA_GENERACION><FECHA_DEBITO_ORIGINAL><ANO>2001</ANO><MES>09</MES><DIA>20</DIA></FECHA_DEBITO_ORIGINAL></DEBITO_DIRECTO></SERVICIOS></!
CONSULTAS></RIOCELULAR>
************************************************************************
Visite http://www.bancorio.com.ar y tenga el Banco al alcance de su mano.
************************************************************************
NOTA DE CONFIDENCIALIDAD / CONFIDENTIALITY NOTE
Este mensaje (y sus anexos) es confidencial y puede contener informacion
(i) de propiedad exclusiva de Banco Rio de la Plata S.A. sus afiliadas o
subsidiarias; o (ii) amparada por el secreto profesional. Si usted ha
recibido este fax o e-mail por error, por favor comuniquelo
inmediatamente via fax o e-mail y tenga la amabilidad de destruirlo; no
debera copiar el mensaje ni divulgar su contenido a ninguna persona.
Muchas gracias.
This message (including attachments) is confidential. It may also
contain information that (i) is exclusively property of Banco Rio de la
Plata S.A. or its affiliates or subsidiaries; or (ii) is privileged or
otherwise legally exempt from disclosure. If you have received it by
mistake please let us know by fax or e-mail immediately and destroy or
delete it from your files or system; you should also not copy the
message nor disclose its contents to anyone. Thank you.
**************************************************************************
begin:vcard
n:Kriger;Julio
tel;work:Interno 4518
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:[EMAIL PROTECTED]
x-mozilla-cpt:;0
fn:Julio Kriger
end:vcard