Subject: Re: [xsl] saxon xmlspy discrepancy in whitespace handling From: George Cristian Bina <george@xxxxxxxxxxxxx> Date: Wed, 17 Jan 2007 12:02:56 +0200 |
Look at buit-in template rules in the XSLT specification http://www.w3.org/TR/xslt20/#built-in-rule
Text nodes are copied to the output by this built in template <xsl:template match="text()|@*" mode="#all"> <xsl:value-of select="string(.)"/> </xsl:template>
Add <xsl:template match="text()"/> to your stylesheet and you should obtain your desired result.
Best Regards, George --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com
Hi,
I write my xsl in xmlspy (version 2006 sp2) and use saxon 8804 to do the transformation in java code. I get the following discrepancy in the produced output, saxon seems to produce extra white space. I know that saxon is the more specification compliant of the two processors, but xmlspy does what I want. So I know that I am missing something fundamental here and I would be grateful for some help.
The immediate question is, how do I get saxon to produce the output I want, shown by the xmlspy output? And secondly, what am I not understanding about whitespace handling in xsl?
Thank you for your attention.
Erwin
Here is my example code that demostrates the problem:
-- begin xml-- <?xml version="1.0" encoding="UTF-8"?> <top>
<section name="AAA" />
<section name="BBB" />
</top> -- end xml --
-- begin xsl -- ?xml version="1.0" encoding="UTF-8"?> <?altova_samplexml C:\workspaces\rad\garuda\storage\example.xml?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<xsl:output method="text" version="1.0" encoding="iso-8859-1" />
<xsl:variable name="newline"><xsl:text> </xsl:text></xsl:variable>
<xsl:template match="/"> <xsl:apply-templates /> </xsl:template>
<xsl:template match="//section" > <xsl:call-template name="section-header" /> </xsl:template>
<xsl:template name="section-header" > <xsl:value-of select="@name"/> <xsl:value-of select="$newline"/> </xsl:template>
</xsl:stylesheet> -- end xsl --
-- begin xmlspy output -- AAA BBB
-- end xmlspy output --
-- begin saxon output --
AAA
BBB
-- end saxon output -
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] saxon xmlspy discrepancy , Geert Bormans | Thread | Re: [xsl] saxon xmlspy discrepancy , Abel Braaksma |
Re: [xsl] saxon xmlspy discrepancy , Geert Bormans | Date | Re: [xsl] saxon xmlspy discrepancy , Abel Braaksma |
Month |