Problems when trying to keep , after XSL transformation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bizt

    Problems when trying to keep , after XSL transformation

    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(',' , '&#44;', $str); // &#44; 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>&#44 ;</xsl:text>', $str);

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

    <xsl:output method="text" encoding="iso-8859-1" indent="no"/>
    $str = str_replace(',' , '&#44;', $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
  • Martin Honnen

    #2
    Re: Problems when trying to keep &amp;#44; after XSL transformation

    bizt wrote:
    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:


    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.

    --

    Martin Honnen

    Comment

    • Joseph J. Kesselman

      #3
      Re: Problems when trying to keep &amp;#44; after XSL transformation

      As far as the XML standard is concerned, there is absolutely no
      difference between &#44; 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 &#44;.

      Comment

      Working...