preserve-space elements="manufacturer" : preserve space « XSLT stylesheet « XML






preserve-space elements="manufacturer"



File: Data.xml
<?xml version="1.0" encoding="utf-8"?>
<cars>
  <manufacturer name="          Chevrolet

">
    <car>A</car>
    <car>B</car>
    <car>C</car>
    <car>D



    </car>
  </manufacturer>
</cars>


File: Transform.xslt

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:preserve-space elements="manufacturer"/>
  <xsl:strip-space elements="cars"/>

  <xsl:template match="/">
    <xsl:copy-of select="."/>
  </xsl:template>

</xsl:stylesheet>

Output:

<?xml version="1.0" encoding="UTF-8"?><cars><manufacturer name="          Chevrolet  ">
    <car>A</car>
    <car>B</car>
    <car>C</car>
    <car>D



    </car>
  </manufacturer></cars>

 








Related examples in the same category