passing a space

D

David Schwartz

I have a template that searches for and replaces found instances of
strings in other strings and replaces them with yet another string.
These strings are passed to the template as parameters, not
surprisingly. It so happens at the moment that I need to replace
instances of spaces with a plus sign. Unfortunately, I don't know how
to pass a space effectively, the template just doesn't get it.

Any thoughts re how to fix this would be appreciated!

TIA,
David
 
G

George Bina

Hi David,

You are not saying how you pass the parameters... Are you passing them
from a call-template instruction?
In that case I do not see the difficulty with that, just enclose the
space in apostrophes if you put that in the select attribute.

<xsl:with-param name="p" select="' '"/>

Regards,
George
 
D

David Schwartz

Are you passing them from a call-template instruction?

Yes, that's how they're being passed but when I use this syntax,
<xsl:with-param name="p" select="' '"/>, I get an 'Empty expression'
error from the processor (XALAN). Isn't the 'select' attribute
reserved for nodes? I've been using "<xsl:with-param name="p"> </
xsl:with-param>" to no avail.

David
 
P

Pavel Lepin

<[email protected]>:

[problems passing space as a parameter to a template]
Yes, that's how they're being passed but when I use this
syntax, <xsl:with-param name="p" select="' '"/>, I get an
'Empty expression' error from the processor (XALAN). Isn't
the 'select' attribute reserved for nodes?
No.

I've been using
"<xsl:with-param name="p"> </xsl:with-param>" to no avail.

Works just fine for me with xsltproc, Saxon-8B, xalan-c++:

pavel@debian:~/dev/xslt$ a param_space.xsl
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput indent="yes"/>
<xsl:template match="/">
<xsl:call-template name="named">
<xsl:with-param name="str" select="' '"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="named">
<xsl:param name="str"/>
<result>
<xsl:value-of select="$str"/>
</result>
</xsl:template>
</xsl:stylesheet>
pavel@debian:~/dev/xslt$ xsltproc param_space.xsl
param_space.xsl
<?xml version="1.0"?>
<result> </result>
pavel@debian:~/dev/xslt$ saxon -t param_space.xsl
param_space.xsl
Saxon 8.8J from Saxonica
Java version 1.5.0_11
Warning: at xsl:stylesheet on line 2 of
file:/var/www/dev/xslt/param_space.xsl:
Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
Stylesheet compilation time: 892 milliseconds
Processing file:/var/www/dev/xslt/param_space.xsl
Building tree for file:/var/www/dev/xslt/param_space.xsl
using class net.sf.saxon.tinytree.TinyBuilder
Tree built in 4 milliseconds
Tree size: 24 nodes, 0 characters, 9 attributes
<?xml version="1.0" encoding="UTF-8"?>
<result> </result>Execution time: 138 milliseconds
Memory used: 576184
NamePool contents: 14 entries in 14 chains. 7 prefixes, 8
URIs
pavel@debian:~/dev/xslt$ xalan -in param_space.xsl -xsl
param_space.xsl
<?xml version="1.0" encoding="UTF-8"?>
<result> </result>
pavel@debian:~/dev/xslt$

Perhaps the problem lies elsewhere. Try reproducing it in a
minimum possible transformation.
 
D

David Schwartz

When I use <xsl:with-param name="p" select="'e'"/> (for testing
purposes, NOTE: NOT a space), I get the following result:

JVMDG217: Dump Handler is Processing Signal 11 - Please Wait.
JVMDG303: JVM Requesting Java core file
JVMDG304: Java core file written to Z:\aDL\Design Patterns\GSA content
\javacore.20071008.081548.7900.txt
JVMDG215: Dump Handler has Processed Exception Signal 11.

When I use <xsl:with-param name="p">e</xsl:with-param>, it works like
a charm.

FYI, I'm using XALAN v.2.7.0.

David
 
J

Joseph Kesselman

Nothing should *ever* trigger a Java Dump. This is not an XML problem,
it's a Java problem. Report this to the Xalan folks, telling them
exactly which JVM you're working with, and preferably giving them
samples of the input document and stylesheet.
 
D

David Schwartz

Nothing should *ever* trigger a Java Dump. This is not an XML problem,
it's a Java problem. Report this to the Xalan folks, telling them
exactly which JVM you're working with, and preferably giving them
samples of the input document and stylesheet.

Thx. Done.
 
R

Richard Tobin

David Schwartz said:
Yes, that's how they're being passed but when I use this syntax,
<xsl:with-param name="p" select="' '"/>, I get an 'Empty expression'
error from the processor (XALAN).

As others have said, this should work.
I've been using "<xsl:with-param name="p"> </xsl:with-param>" to no avail.

This *won't* work, because of whitespace stripping. Add an
xml:space="preserve" attribute to the xsl:with-param element.

-- Richard
 
J

Joseph Kesselman

Richard said:
This *won't* work, because of whitespace stripping. Add an
xml:space="preserve" attribute to the xsl:with-param element.

Or use
<xsl:with-param name="p"><xsl:text> </xsl:text></xsl:with-param>

Good catch; I wasn't reading that closely.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,008
Messages
2,570,271
Members
46,875
Latest member
TabithaSta

Latest Threads

Top