By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,271 Members | 1,319 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,271 IT Pros & Developers. It's quick & easy.

passing a space

P: n/a
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

Oct 8 '07 #1
Share this Question
Share on Google+
6 Replies

P: n/a
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
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Oct 8 '07 #2

P: n/a
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

Oct 8 '07 #3

P: n/a

David Schwartz <da******@gmail.comwrote in
<11*********************@22g2000hsm.googlegroups.c om>:

[problems passing space as a parameter to a template]
>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?
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:output 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.

--
It is rare to find learned men who are clean, do not stink,
and have a sense of humour. -- Liselotte in a letter to
Sophie, 30 Jul 1705
Oct 8 '07 #4

P: n/a
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

Oct 8 '07 #5

P: n/a
In article <11*********************@22g2000hsm.googlegroups.c om>,
David Schwartz <da******@gmail.comwrote:
>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

--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Oct 8 '07 #6

P: n/a
Richard Tobin wrote:
>>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.
Or use
<xsl:with-param name="p"><xsl:text</xsl:text></xsl:with-param>

Good catch; I wasn't reading that closely.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Oct 8 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.