[xslt] XML with curly braces {} cannot be parsed.



Please could anybody give me a hint to make the following work. I get errors
using Gnome XSLT on XML strings received from a remote SOAP server. Some of
these messages cannot be parsed. I think the problem lies in the curly
braces ( { } ) contained in the XML. If I replace the { and } by blanks,
everything works OK.

I use libxml2 -2.4.26 and libxslt-1.0.22.  In the included C code it is the
xmlParseMemory( , ) that returns NULL.
Below an example of a message that cannot be parsed, and the C code used.

Thanks in advance,
			Albert.Dijk   (@atosorigin.com) 


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="C:\Dataprv\MC\WebSelfcare\AutorServ\LT830_OUT.xsl"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
	<soapenv:Body>
		<soapenv:Fault>
			<faultcode
xmlns:ns1="http://xml.apache.org/axis/";>ns1:Server.NoService</faultcode>
			<faultstring>The AXIS engine could not find a target
service to invoke!  targetService is null</faultstring>
			<detail>
				<ns2:stackTrace
xmlns:ns2="http://xml.apache.org/axis/";>AxisFault
 faultCode: {http://xml.apache.org/axis/}Server.NoService
 faultString: The AXIS engine could not find a target service to invoke!
targetService is null
 faultActor: null
 faultDetail: 

The AXIS engine could not find a target service to invoke!  targetService is
null
	at org.apache.axis.server.AxisServer.invoke(AxisServer.java:307)
	
Xslt_BackendClient.CallBackend> Found the RootTag: FALSE
Xslt_BackendClient.CallBackend> Incomplete Response: at
org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:701)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at
org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:
335)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServl
etRunner.java:919)
	at
com.iplanet.server.http.servlet.WebApplication.service(WebApplication.java:1
061)
	at
com.iplanet.server.http.servlet.NSServletRunner.ServiceWebApp(NSServletRunne
r.java:981)
</ns2:stackTrace>
			</detail>
		</soapenv:Fault>
	</soapenv:Body>
</soapenv:Envelope>

 
#include <string.h>
#include "xmlmemory.h"
#include "debugXML.h"
#include "HTMLtree.h"
#include "xmlIO.h"
#include "DOCBparser.h"
#include "xinclude.h"
#include "catalog.h"
#include "xslt.h"
#include "xsltInternals.h"
#include "transform.h"
#include "xsltutils.h"
#include <stdio.h>
#include <stdlib.h>


extern int xmlLoadExtDtdDefaultValue;
char *pErrorText[6];	
/*	function:	transformXml
 *
============================================================================
===
 *	Transform the given xml file with the givven xslt file
 *  	and save the result in the given xml output file
 *
 *	ARGUMENTS
 *	xmlContentRaw	= the content of the XML
(Input)
 *	xsltFile	= the location of the XSLT file
(Input)
 *	xmlTransformed	= The transformd XML data
(Output)
 *
 *	RETURN
 *	0 if OK else > 0
 *
 */

int transformXml(const char *xmlContentRaw,const char *xsltFile,char
**xmlTransformed) 
{	
	//Declarations
	xsltStylesheetPtr cur = NULL;
	xmlDocPtr doc, res;
	xmlOutputBufferPtr buf;
	xmlChar *mem;
	char *cMem;
	
	int iMemSize=0;
	
	xmlSubstituteEntitiesDefault(1);	//Initialisation
	xmlLoadExtDtdDefaultValue = 1;
	
	if (NULL == xmlContentRaw)
	{
		return(5);
	}
	
	cur = xsltParseStylesheetFile((const xmlChar *)xsltFile); //create a
struct with the XSLT-tree in memory
	if (NULL==cur)
	{
		return(1);
	}
	
	doc = xmlParseMemory(xmlContentRaw,strlen(xmlContentRaw));
//create a struct with the XML-tree in memory
	if (NULL == doc)
	{	
		xsltFreeStylesheet(cur);
//deallocate allocated memory
        	xsltCleanupGlobals();
		return(2);
	}
	
	res = xsltApplyStylesheet(cur, doc, NULL);
//Create a struct with the transformed xml tree in emory
	if (NULL == res)
	{
		xsltFreeStylesheet(cur);
//deallocate allocated memory
		xmlFreeDoc(doc);
        	xsltCleanupGlobals();
        	xmlCleanupParser();
		return(3);
	}
	
	xmlDocDumpMemory(res, &mem, &iMemSize);
	
	cMem =(char*)mem;					//zet de
pointer naar het adres van mem
	*xmlTransformed =  cMem;				//zet in
xmlTransformed de verwijzing naar cMem
	
	xsltFreeStylesheet(cur);
	xmlFreeDoc(res);	
	xmlFreeDoc(doc);	
	xsltCleanupGlobals();		
	xmlCleanupParser();	
	return(0);		
}

/*	function:	error2string
 *
============================================================================
===
 *	Transform the errornumber to a errormessage
 *
 *	ARGUMENTS
 *	errnr		= the number of the error	(Input)
 *
 *	RETURN
 *	If it's a known error else NULL
 *
 */	
char* error2string(const int errnr) 
{
	pErrorText[0]="";
	pErrorText[1]="Could't create xslt tree";
	pErrorText[2]="Could't create xml tree";
	pErrorText[3]="Could't create Transformed xml tree";
	pErrorText[4]="Could't not save xml file";
	pErrorText[5]="xml data is empty";
		
	if (errnr < 1 || errnr > 5) //Unknown errornr!
		return NULL;
	
	return pErrorText[errnr];
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]