How to add Xml stylesheet header to a xmlstring

Hi,

We want to add a xml stylesheet header to a xml string generated from an IS document using documentToXMLString service.

If we set ‘addHeader’ to ‘true’, xml header “<?xml version="1.0" encoding="ISO-8859-15"?>” is getting added. Along with this header, we want stylesheet header also in the xml.

Our xml string should look like:

<?xml version="1.0" encoding="ISO-8859-15"?> <?xml-stylesheet type="text/xsl" href="Finvoice.xsl"?>

where is the first level xml tag.

We tried adding a document ‘?xml-stylesheet’ with attirbutes ‘@type’ & ‘@href’ but that document was considered as a tag and xml data becomes a invalid xml due to two tags ‘xml-stylesheet’ & ‘Finvoice’ at same level.

Please advise.

What system is flagging the XML as not well-formed? Is it IS? Is something generating an error?

As far as I can tell the xml-stylesheet processing instruction is correct and in the right place. According to http://www.w3.org/TR/xml-stylesheet/ “The xml-stylesheet processing instruction is parsed in the same way as a start-tag…” so perhaps it just looks to be not well-formed during processing but in fact actually is.

I think I haven`t written my case properly. Actually I want final xml to look like below:

<?xml version="1.0" encoding="ISO-8859-15"?> <?xml-stylesheet type="text/xsl" href="Finvoice.xsl"?>

But to acheive this, we tried adding a document ‘?xml-stylesheet’ with attirbutes ‘@type’ & ‘@href’ with appropriate values and finally we got the xml string output as below:

<?xml version="1.0" encoding="ISO-8859-15"?> <?xml-stylesheet type="text/xsl" href="Finvoice.xsl"/> which was throwing an invalid xml error when we try to open it in browser. So my actual query on the post is, how to add a proper stylesheet header to my xml string?

A search of Advantage shows that this type of question has been asked before but not resolved. Bummer.

One way to do this is to set addHeader to false on the documentToXMLString call and then prepend the desired prolog (declaration and processing instruction) to the string using pub.string:concat. Not memory friendly but workable.

Perhaps tech support would have a better idea. Or maybe there is an unadvertised fix/enhancement available for properly handling processing instructions in both documentToXMLString and xmlStringToXMLNode/xmlNodeToDocument.

Thanks Reamon. As a temporary fix, we have used the concat service & acheived it.

Will raise a case to Tech Team and let u know once we got any reply.