Problems when trying to keep , after XSL transformation

B

bizt

Hi,

I am performing an XSLT on a XML feed. The XSLT produces me with PHP
code that I eval then insert into my DB. However, the way that the
system Im assigned to is setup, I need to convert all instances of
comma ',' to entity ',' .. so this requires that the output of the
XSLT needs to produce ',' but instead it converts it to a comma
which the current system doesnt like when handling it.

Below shows a snippet of what I have. What is happening here is that a
text output of PHP code is produced that I will then go on to execute
using PHP eval():

<xsl:template ...>

function ConvertString($str) {
$str = str_replace(',', ',', $str); // , gets converted to a
comma during the XSLT
return $str;
}

</xsl:template>



Ive tried a number of things such as :

$str = str_replace(',', '&amp;#44;', $str);

$str = str_replace(',', '<xsl:text>,</xsl:text>', $str);

$str = str_replace(',', '<![CDATA[,]]>', $str);

<xsl:eek:utput method="text" encoding="iso-8859-1" indent="no"/>
$str = str_replace(',', ',', $str);

... all with different outputs but none doing what I need.

Can anyone tell me how to output entities as a result of the XSLT?
Thanks

Burnsy
 
M

Martin Honnen

bizt said:
Can anyone tell me how to output entities as a result of the XSLT?

You will have to check the documentation of your XSLT processor whether
you can plug in a custom serializer and then you will have to implement
that serializer.

Or you could try an XSLT 2.0 processor and character maps:
http://www.w3.org/TR/xslt20/#character-maps

There are currently three XSLT 2.0 processors, Saxon, Gestalt, and
AltovaXML tools.
Saxon comes as a Java and as a .NET version: http://saxon.sourceforge.net/.
Gestalt is available at http://gestalt.sourceforge.net/.
Altova at http://www.altova.com/altovaxml.html, it is COM solution with
Java and .NET bindings.
 
J

Joseph J. Kesselman

As far as the XML standard is concerned, there is absolutely no
difference between , and the comma character. I would suggest fixing
whatever tool you're using that cares about this difference... or
finding another solution for marking up this distinction, such as
<comma>... or just run a postprocessor after the XSL transformation that
does a character-replace of all commas with ,.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top