Error using .NET to transform XML to HTML in webspeed with E

Posted by christian.bryan@capita.co.uk on 28-Sep-2018 09:48

HI All 

We have a strange issue with using the following code in webspeed to transform XML documents to HTML using XSLT.

If non-ascii characters in the XML we get the following error in the webspeed log:

>>>>>>>>

System.Xml.XmlException: Unexpected end of file while parsing Name has occurred. Line 2, position 39946.

<<<<<<<<<

We cannot recreate this in the a gui client though.

CODE:

DEFINE INPUT PARAMETER i-xml-doc AS HANDLE NO-UNDO.
DEFINE INPUT PARAMETER i-xsl-name AS CHARACTER NO-UNDO.

DEF VAR lv-myStringReader AS System.IO.StringReader NO-UNDO.
DEF VAR lv-myStringWriter AS System.IO.StringWriter NO-UNDO.
DEF VAR lv-myXpathDoc AS System.Xml.XPath.XPathDocument NO-UNDO.
DEF VAR lv-myXslTrans AS System.Xml.Xsl.XslCompiledTransform NO-UNDO.
DEF VAR lv-MyXMLWriter AS System.Xml.XmlWriter NO-UNDO.

DEF VAR lv-XMLString AS LONGCHAR NO-UNDO.
DEF VAR lv-Output AS LONGCHAR NO-UNDO.

i-xml-doc:SAVE("LONGCHAR", lv-XMLString).

lv-myStringReader = NEW System.IO.StringReader(lv-xmlString).
lv-myXPathDoc = NEW System.Xml.XPath.XPathDocument(lv-myStringReader).
lv-myXslTrans = NEW System.Xml.Xsl.XslCompiledTransform().


/* load the Xsl */
lv-myXslTrans:Load(SEARCH(i-xsl-name)).

/* create the output stream */
lv-myStringWriter = NEW System.IO.StringWriter().
lv-MyXMLWriter = System.Xml.XmlWriter:CREATE(lv-myStringWriter, lv-myXslTrans:OutputSettings).

/* Do the actual transform of Xml */
lv-myXslTrans:Transform(lv-myXPathDoc, lv-myXMLWriter).

lv-Output = lv-myStringWriter:ToString().

/* Copy longchar to webstream */
{&OUT-LONG} lv-Output.

DELETE OBJECT lv-myStringReader NO-ERROR.
DELETE OBJECT lv-myXPathDoc NO-ERROR.
DELETE OBJECT lv-myXslTrans NO-ERROR.
DELETE OBJECT lv-myStringWriter NO-ERROR. 
DELETE OBJECT lv-MyXMLWriter NO-ERROR.

XML and XSL document:

All Replies

Posted by christian.bryan@capita.co.uk on 28-Sep-2018 09:51

XML Files

[View:/cfs-file/__key/communityserver-discussions-components-files/19/XML_5F00_XSL.zip:320:240]

Posted by christian.bryan@capita.co.uk on 28-Sep-2018 10:16

I think i have solved the issue although i am not sure why?

We had the following in our .pf  for the webspeed broker

-cpinternal UTF-8

-cpstream UTF-8

Commenting these out and the transformation occurs normally

This thread is closed