You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Olsen, Per Hoffmann" <pe...@netway.ag> on 2001/11/06 16:46:49 UTC

Xalan-Java version 2.2.D11 feedback - problem with substring!

Hi Xalan dev

I have strange problem in the 2.2.D9 and 2.2.D11 Xalan version.

When running this simple XSL 

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" encoding="iso-8859-1"/>

<xsl:template match="/">
<xsl:variable name="target">
Hello<b>World</b>
</xsl:variable>
<xsl:copy-of select="substring($target,'1','20')"/>
<xsl:copy-of select="$target"/>
</xsl:template>

</xsl:stylesheet>

It Returns:

HelloWorld
Hello<b>World</b>

and not what i would expect

Hello<b>World</b>
Hello<b>World</b>

Why is that so?

Kind Regards
Per Hoffmann Olsen
Netway.at 
Vienna - Austria


PS: As input you can use any xml file, like -
<doc>
Some data
</doc>


RE: Xalan-Java version 2.2.D11 feedback - problem with substring!

Posted by Gunnlaugur Thor Briem <gt...@dimon.is>.
Hi Per,

This is because the substring function takes a string argument.
It doesn't operate on arbitrary structured data (what would it
mean to take a substring of a tree?). If what you pass to it
isn't a string (in this case it is a result tree fragment),
then it is converted to a string. Converting a result tree
fragment to a string just means taking all pieces of text
content from it and concatenating them into a single string.

You'll probably find that the same thing happens in any other
compliant XSLT processor. That's the way it's supposed to be.

Unless I'm missing something! :)

Cheers,

	- Gulli




> -----Original Message-----
> From: Olsen, Per Hoffmann [mailto:per.olsen@netway.ag]
> Sent: 6. nóvember 2001 15:47
> To: 'xalan-dev@xml.apache.org'
> Subject: Xalan-Java version 2.2.D11 feedback - problem with substring!
>
>
> Hi Xalan dev
>
> I have strange problem in the 2.2.D9 and 2.2.D11 Xalan version.
>
> When running this simple XSL
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="xml" encoding="iso-8859-1"/>
>
> <xsl:template match="/">
> <xsl:variable name="target">
> Hello<b>World</b>
> </xsl:variable>
> <xsl:copy-of select="substring($target,'1','20')"/>
> <xsl:copy-of select="$target"/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> It Returns:
>
> HelloWorld
> Hello<b>World</b>
>
> and not what i would expect
>
> Hello<b>World</b>
> Hello<b>World</b>
>
> Why is that so?
>
> Kind Regards
> Per Hoffmann Olsen
> Netway.at
> Vienna - Austria
>
>
> PS: As input you can use any xml file, like -
> <doc>
> Some data
> </doc>
>