You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Maynard <ma...@organic.com> on 2001/11/14 20:31:28 UTC
Is this a bug, or am I missing something?
I'm having difficulty getting xsl:strip-space to work with XML assets
loaded with the document function. It seems that xsl:strip-space gets
applied correctly to the main document being transformed, but documents
loaded with the document function don't get their whitespace trimmed. Is
this a bug in Xalan, or is this the intended behaviour. I'm using Xalan 2.1.0.
Below are test files that demonstrate this behaviour. Is there any way
around this issue other than using an additional match rule like:
<xsl:template match="text()"><xsl:value-of
select="normalize-space(.)"/></xsl:template>, which strips more whitespace
then I really want to.
Here's a test.xsl:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lxslt="http://xml.apache.org/xslt"
>
<xsl:output indent="no" method="html"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:apply-templates/>
<xsl:apply-templates select="document('test2.xml')/doc"/>
</xsl:template>
<xsl:template match="element">[<xsl:apply-templates/>]</xsl:template>
</xsl:stylesheet>
Here's text.xml, the file main file being transformed:
<?xml version="1.0"?>
<doc>
<element>abc</element> <element>def</element>
</doc>
Here's test2.xml the file being loaded by the document() function:
<?xml version="1.0"?>
<doc>
<element>123</element> <element>456</element>
</doc>
Here's the generated ouput:
[abc][def]
[123] [456]
And the expected output:
[abc][def]
[123][456]
--------------------------------------
Maynard Demmon - Senior Interface Eng.
(415) 581-5394 - maynard@organic.com
Organic, Inc.
601 Townsend Street
San Francisco, CA 94103
--------------------------------------
RE: Is this a bug, or am I missing something?
Posted by Maynard Demmon <ma...@organic.com>.
Thanks, I'll see if I can get a later version working. Also I found the bug
number for this issue in bugzilla, it's 1152.
>Maynard --
>
>I just tried this with the current CVS version of XalanJ and received
>the following output:
>
>[abc][def][123][456]
>
>Whitespace handling has changed significantly since 2.1.0. It looks
>like this problem has been fixed.
>
>Gary
>
>> -----Original Message-----
>> From: Maynard [mailto:maynard@organic.com]
>> Sent: Wednesday, November 14, 2001 11:31 AM
>> To: xalan-dev@xml.apache.org
>> Subject: Is this a bug, or am I missing something?
>>
>>
>> I'm having difficulty getting xsl:strip-space to work with
>> XML assets loaded with the document function. It seems that
>> xsl:strip-space gets applied correctly to the main document
>> being transformed, but documents loaded with the document
>> function don't get their whitespace trimmed. Is this a bug in
>> Xalan, or is this the intended behaviour. I'm using Xalan 2.1.0.
>>
>> Below are test files that demonstrate this behaviour. Is
>> there any way around this issue other than using an
>> additional match rule like: <xsl:template
>> match="text()"><xsl:value-of
>> select="normalize-space(.)"/></xsl:template>, which strips
>> more whitespace then I really want to.
>>
>> Here's a test.xsl:
>> <?xml version="1.0" encoding="iso-8859-1"?>
>> <xsl:stylesheet
>> version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> xmlns:lxslt="http://xml.apache.org/xslt"
>> >
>> <xsl:output indent="no" method="html"/>
>> <xsl:strip-space elements="*"/>
>> <xsl:template match="/">
>> <xsl:apply-templates/>
>> <xsl:apply-templates
>> select="document('test2.xml')/doc"/>
>> </xsl:template>
>> <xsl:template
>> match="element">[<xsl:apply-templates/>]</xsl:template>
>> </xsl:stylesheet>
>>
>> Here's text.xml, the file main file being transformed:
>> <?xml version="1.0"?>
>> <doc>
>> <element>abc</element> <element>def</element>
>> </doc>
>>
>> Here's test2.xml the file being loaded by the document()
>> function: <?xml version="1.0"?> <doc>
>> <element>123</element> <element>456</element>
>> </doc>
>>
>> Here's the generated ouput:
>> [abc][def]
>> [123] [456]
>>
>> And the expected output:
>> [abc][def]
>> [123][456]
>>
>> --------------------------------------
>> Maynard Demmon - Senior Interface Eng.
>> (415) 581-5394 - maynard@organic.com
>>
>> Organic, Inc.
>> 601 Townsend Street
>> San Francisco, CA 94103
>> --------------------------------------
>>
--------------------------------------
Maynard Demmon - Senior Interface Eng.
(415) 581-5394 - maynard@organic.com
Organic, Inc.
601 Townsend Street
San Francisco, CA 94103
--------------------------------------
Re: Is this a bug, or am I missing something?
Posted by Peter Davis <pe...@speaklink.com>.
So it looks like <xsl:strip-space> is not being applied to the elements
in a document that is imported with document(...). A quick scan of the
spec mentions nothing about this, so (even though I'm not actually a
Xalan developer) it looks like a bug to me. A workaround might be to do
this, though:
<xsl:template match="doc">
<xsl:apply-templates select="node()"/>
</xsl:template>
That way the extra whitespace elements in <doc> will not be selected.
(Note that I haven't tested this myself.)
Maynard wrote:
>I'm having difficulty getting xsl:strip-space to work with XML assets
>loaded with the document function. It seems that xsl:strip-space gets
>applied correctly to the main document being transformed, but documents
>loaded with the document function don't get their whitespace trimmed. Is
>this a bug in Xalan, or is this the intended behaviour. I'm using Xalan 2.1.0.
>
>Below are test files that demonstrate this behaviour. Is there any way
>around this issue other than using an additional match rule like:
><xsl:template match="text()"><xsl:value-of
>select="normalize-space(.)"/></xsl:template>, which strips more whitespace
>then I really want to.
>
>Here's a test.xsl:
><?xml version="1.0" encoding="iso-8859-1"?>
><xsl:stylesheet
> version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:lxslt="http://xml.apache.org/xslt"
>
> <xsl:output indent="no" method="html"/>
> <xsl:strip-space elements="*"/>
> <xsl:template match="/">
> <xsl:apply-templates/>
> <xsl:apply-templates select="document('test2.xml')/doc"/>
> </xsl:template>
> <xsl:template match="element">[<xsl:apply-templates/>]</xsl:template>
></xsl:stylesheet>
>
>Here's text.xml, the file main file being transformed:
><?xml version="1.0"?>
><doc>
> <element>abc</element> <element>def</element>
></doc>
>
>Here's test2.xml the file being loaded by the document() function:
><?xml version="1.0"?>
><doc>
> <element>123</element> <element>456</element>
></doc>
>
>Here's the generated ouput:
>[abc][def]
> [123] [456]
>
>And the expected output:
>[abc][def]
>[123][456]
>
>--------------------------------------
>Maynard Demmon - Senior Interface Eng.
>(415) 581-5394 - maynard@organic.com
>
> Organic, Inc.
> 601 Townsend Street
> San Francisco, CA 94103
>--------------------------------------
>
>
>
--
Furthermore, I believe bacon prevents hair loss.
Peter Davis
Developer, Speaklink Inc.
peter@speaklink.com
RE: Is this a bug, or am I missing something?
Posted by Gary L Peskin <ga...@firstech.com>.
Maynard --
I just tried this with the current CVS version of XalanJ and received
the following output:
[abc][def][123][456]
Whitespace handling has changed significantly since 2.1.0. It looks
like this problem has been fixed.
Gary
> -----Original Message-----
> From: Maynard [mailto:maynard@organic.com]
> Sent: Wednesday, November 14, 2001 11:31 AM
> To: xalan-dev@xml.apache.org
> Subject: Is this a bug, or am I missing something?
>
>
> I'm having difficulty getting xsl:strip-space to work with
> XML assets loaded with the document function. It seems that
> xsl:strip-space gets applied correctly to the main document
> being transformed, but documents loaded with the document
> function don't get their whitespace trimmed. Is this a bug in
> Xalan, or is this the intended behaviour. I'm using Xalan 2.1.0.
>
> Below are test files that demonstrate this behaviour. Is
> there any way around this issue other than using an
> additional match rule like: <xsl:template
> match="text()"><xsl:value-of
> select="normalize-space(.)"/></xsl:template>, which strips
> more whitespace then I really want to.
>
> Here's a test.xsl:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet
> version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:lxslt="http://xml.apache.org/xslt"
> >
> <xsl:output indent="no" method="html"/>
> <xsl:strip-space elements="*"/>
> <xsl:template match="/">
> <xsl:apply-templates/>
> <xsl:apply-templates
> select="document('test2.xml')/doc"/>
> </xsl:template>
> <xsl:template
> match="element">[<xsl:apply-templates/>]</xsl:template>
> </xsl:stylesheet>
>
> Here's text.xml, the file main file being transformed:
> <?xml version="1.0"?>
> <doc>
> <element>abc</element> <element>def</element>
> </doc>
>
> Here's test2.xml the file being loaded by the document()
> function: <?xml version="1.0"?> <doc>
> <element>123</element> <element>456</element>
> </doc>
>
> Here's the generated ouput:
> [abc][def]
> [123] [456]
>
> And the expected output:
> [abc][def]
> [123][456]
>
> --------------------------------------
> Maynard Demmon - Senior Interface Eng.
> (415) 581-5394 - maynard@organic.com
>
> Organic, Inc.
> 601 Townsend Street
> San Francisco, CA 94103
> --------------------------------------
>