I'm trying to write an XSLT for using ImageGen. Everything works quite well, but I just don't seem to find any way to get the Ampersand (&) output as a single char and not as &
I used <xsl:text disable-output-escaping="yes">&</xsl:text> but it just gives me &
@Doug: I already tried this, but everything I get is & doesn't matter if I use & directly oder inside a <xsl:text disable-output-escaping="yes">&</xsl:text>
But it must be possible anyhow I can't be the only one trying this?!?
Aw... I'm such a fool... your're right - off course - both of you. I just had a dumb misstype in my line and thought the error was caused by the &'s!
Sorry to bother you and big big thanx for helping!
Thanks for that snippet. I also thought I saw something to be added to the ENITY at top of the xslt-file which could also solve this (just like there's the nbsp), did look for it yesterday but couldn't find it.
Because & is a built-in character and the '&' symbol is a marker of the beginning of entities I don't think you can short-circuit the & in xslt. There's a small discussion of entities in my blogpost about the "Anatomy of an umbraco XSLT file" (http://blog.percipientstudios.com/2009/4/11/anatomy-of-an-umbraco-xslt-file.aspx). You'll see that & is one of the five built-in entities.
Still, if anyone finds a way to do it, I'd love to hear about it!!
okay, i know i saw something somewhere about the & and inline xslt when it is related to imagegen stuff... but can't find it to save my life... little help?
If you create a new thread for this, you can be more specific and post some code; and more people will see it, thus being able to help you with your specific version of this problem.
How to get the Ampersand output as single char?
Hello,
I'm trying to write an XSLT for using ImageGen. Everything works quite well, but I just don't seem to find any way to get the Ampersand (&) output as a single char and not as &
I used <xsl:text disable-output-escaping="yes">&</xsl:text> but it just gives me &
I guess its totaly simple but I don't find how!
Looking forward for your help,
Arnim.
Use
when in xslt
Dan
http://www.w3schools.com/tags/ref_entities.asp
@Dan: Won't work   shows nothing and using $ I get & on the output side again.
Do I have to set a specific out-format or some escaping or something?
There's a looong discussion about this on the old forum. Here's the summary...
The & character is not a valid character by itself in XSLT, there is only the & sequence. No good way around that.
When creating querystring parameters (for ImageGen, for instance) you want to have something like:
But with XSLT you'll only ever get the following:
UNLESS... you change your xslt output method to 'html'.
cheers,
doug.
@Doug: I already tried this, but everything I get is & doesn't matter if I use & directly oder inside a <xsl:text disable-output-escaping="yes">&</xsl:text>
But it must be possible anyhow I can't be the only one trying this?!?
Arnim, in a URL it's totally valid to actually use "&". What's the specific reason tha you need to output just a single ampersand?
To be honest, I've never found any reason to require that.
Sorry, had a brain cramp while typing the summary of the situation. I don't know what I was saying with the output method... not relevant.
The real conclusion is...
There is NO problem with having the '&' appear on the querystring. Every browser will support it just as if it were only the '&' character.
For instance, I do this kind of thing all the time and it works in every browser I've ever tested it on:
So, don't worry about the expanded ampersand; it's just fine even though it looks a bit ugly.
cheers,
doug.
Aw... I'm such a fool... your're right - off course - both of you. I just had a dumb misstype in my line and thought the error was caused by the &'s!
Sorry to bother you and big big thanx for helping!
Greets, Arnim.
BTW there (of course) is way how to write it :-)
<xsl:variable name="and"><![CDATA[&]]></xsl:variable>
<xsl:value-of select="concat('umbraco is great ', $and, ' powerfull')"
disable-output-escaping="yes"/>
Petr
@Petr
Thanks for that snippet. I also thought I saw something to be added to the ENITY at top of the xslt-file which could also solve this (just like there's the nbsp), did look for it yesterday but couldn't find it.
@Peter
Maybe this is what are you looking for:
http://forum.umbraco.org/yaf_postst4594_How-do-I-achieve-andlaquo-and-raquo-in-XSLT.aspx
Yes, that was it! Thnx
Because & is a built-in character and the '&' symbol is a marker of the beginning of entities I don't think you can short-circuit the & in xslt. There's a small discussion of entities in my blogpost about the "Anatomy of an umbraco XSLT file" (http://blog.percipientstudios.com/2009/4/11/anatomy-of-an-umbraco-xslt-file.aspx). You'll see that & is one of the five built-in entities.
Still, if anyone finds a way to do it, I'd love to hear about it!!
cheers,
doug.
okay, i know i saw something somewhere about the & and inline xslt when it is related to imagegen stuff... but can't find it to save my life... little help?
found it...
To insert an ampersand in inline xslt you must use &amp;
This is quite a common problem when doing complex XML type encoding.
So you need to write,
&amp;height=200&amp;width=500 ... Etc
I am getting XML data from an external service which already has the ampersand as & - now XSLT converts it into &amp;
Is there any solution for this..
I am also facing the same issue. My external XML comes line
If you found solution for this please let me know.
Admin please direct me to the link if the issue is already resolved.
thanks Siddharth
Hi Anz,
If you create a new thread for this, you can be more specific and post some code; and more people will see it, thus being able to help you with your specific version of this problem.
/Chriztian
Can you redirect me to the new thread which was created for the issue highlighted by anz.
thanks siddharth
Do we have a solution for & to be passed as &
is working on a reply...