473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

passing a space

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
6 2494
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
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

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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: BKDotCom | last post by:
Many built-in functions allow an optional variable to be passed for error messages. How do I implement this in my own function? function test($param1, $param2, &$errormsg) { // complains if 3rd...
12
by: harry | last post by:
I have an object that's passed in to a function as a parameter i.e public boolean getProjectTitle(ProjectHeader_DTO obj) {...} If I then call a method on this object inside the function i.e...
6
by: Bryan Martin | last post by:
I have a object that is created in a seperate domain which needs to be passed back to the parent class. Because this object is created in a seperate domain if I try to pass the object back to the...
5
by: lugal | last post by:
This might be more appropriate here. I'm new to C++, coming from a background in another languages that allowed a similar solution to work (Python). I wrote the following code in C++ based on the...
6
by: DeepaK K C | last post by:
Could anybody tell me how to pass array to a function by value? -Deepak
61
by: academic | last post by:
When I declare a reference variable I initialize it to Nothing. Now I'm wondering if that best for String variables - is "" better? With Nothing I assume no memory is set aside nor GC'ed But...
5
by: nass | last post by:
this is a thought experiment. i do not have the time to implement it and test it to see if it works so i am relying on your good will:) thank you in advance im on a linux machine (slackware...
16
by: Theo R. | last post by:
Hi all, Does the C99 Standard explicitly mention the need for a stack for passing arguments or Is this platform specific? As an example, the ARM9 processor recommends Core Registers R0-R3 be...
7
by: pereges | last post by:
which one do you think is better ? I need to make my program efficient and in some places I have passed the copy of a variable which makes life some what easy while writing huge expressions but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.