Menu

Xml output

saxon-help
Felix C
2016-03-03
2016-03-08
  • Felix C

    Felix C - 2016-03-03

    Hi,

    I am using Saxon to transform a xml file into another using this xsl stylesheet:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:saxon="http://saxon.sf.net/">
    
    <xsl:output method="xml" indent="yes" />
    <xsl:strip-space elements="*"/>
    
    <xsl:template match="/">
    <foo>
    .......
    <xsl:text>&#xd;</xsl:text>
    <bar>
    ..........
    </bar>
    <xsl:text>&#xd;</xsl:text>
    <bar>
    ..........
    </bar>
    </foo>
    
    </xsl:template>
    </xsl:stylesheet>
    

    So I am expecting to get something like that:

    <foo>
    
    <bar>........</bar>
    
    <bar>........</bar>
    </foo>
    

    But the result is:

    <foo>&#xd;
    <bar>........</bar>&#xd;
    <bar>........</bar>
    </foo>
    

    I am using the java virtual machine, with the following options:

    java -cp saxon9he.jar net.sf.saxon.Transform -t -s:myInput.xml -xsl:mystylesheet.xsl -o:c:myoutput.xml

    Thanks in advance for any help.

     

    Last edit: Felix C 2016-03-03
  • Michael Kay

    Michael Kay - 2016-03-03

    Please use the Saxonica forum at saxonica.plan.io for saxon-specific questions, and SourceForge for general XSLT questions.

    XML normalizes newlines to a single x0A character. If you just want a new line, output x0A. If you try to output x0D, it is output as a character reference in order to preserve it through end-of-line normalization when the XML file is re-parsed. This is mandated by the W3C specification.

     
    • Felix C

      Felix C - 2016-03-08

      Thank you very much!!