outputting '<' and '>'

outputting '<' and '>'

Post by holden.. » Sat, 28 Oct 2000 03:57:56



How can I output the characters
'<' and '>' from an XSL Stylesheet?

I need to output a line like this:

<a href="<%= response.encodeURL('http://www.foo.com/foo.jsp') %>">

but XSL is having problems with the '<' amd '>' by the percent signs.

I've tried &lt; and &gt; but the characters dont get translated, i.e.
I get "&lt;" and "&gt;" in the output.

Any suggestions?
-Chris

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

outputting '<' and '>'

Post by David Carlisl » Sat, 28 Oct 2000 09:03:07


] I need to output a line like this:
] <a href="<%= response.encodeURL('http://www.foo.com/foo.jsp') %>">

note that this isn't XML, XML attributes can't have a < in their value
and no XML content (except in a CDATA section) can have the sequence <%
as an element name may not begin with % (I assume this is an asp page,
but asp ain't xml)

So you can not use the default XML output method of XSLT and obtain that.
You may be able to use <xsl:output type="html"/> although in that case
any href attributes will be automatically URL encoded by the XSL system.

Even iif you use the html output your stylesheet still has to be well
formed XML, so in the stylesheet use &lt; to refer to a < in the
attribute value.

David

 
 
 

outputting '<' and '>'

Post by Robin Johnso » Sat, 28 Oct 2000 17:52:15



> How can I output the characters
> '<' and '>' from an XSL Stylesheet?

> I need to output a line like this:

> <a href="<%= response.encodeURL('http://www.foo.com/foo.jsp') %>">

> but XSL is having problems with the '<' amd '>' by the percent signs.

The brute force way would be

<xsl:text disable-output-escaping="yes"
 >&lt;a href="&lt;%= ... %&gt;"&gt;</xsl:text>

This is *extremely* bad practice and won't work in certain contexts (like if
you're writing to a result tree fragment which you want to process again
downstream.) But there are circumstances in which it's the only way. The
alternative is to write a perl script (or something) which will sweep over
your output document after you've applied the stylesheet.

--
Robin Johnson

http://www.nondescript.org
"A cup of coffee with a fork, please."

 
 
 

outputting '<' and '>'

Post by Mike Bro » Sun, 29 Oct 2000 16:59:58




Quote:>] I need to output a line like this:
>] <a href="<%= response.encodeURL('http://www.foo.com/foo.jsp') %>">

>note that this isn't XML

Also note that JSP has an alternative to the <% ... %> syntax that is
well-formed XML. Check the JSP specification at java.sun.com. It may not
be completely applicable to this situation with that attribute value, but
the original poster might find it more useful than trying to output the
shorthand.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/

 
 
 

1. Create '<' and '>' by <xsl:eval>

Hi,
I wants to create '<TD>' by an <xsl:eval>, but the parser changes it
into '&lt;TD&gt;'. What could I do ?

Thanks for your help

Frank

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

2. Colouring imported .eps files

3. output of '<', '>'

4. Mis understood.

5. Problems outputting '<' and '>'

6. DNS lookup

7. Redefining Tag Delimiter ('<' --> '[')??

8. Help! Quicktime under Winos2

9. XML and the '<' , '>', single quote chararacters

10. Problem with 'Or' operator in '<xsl:if>' statement

11. PRB: xsl changing '<' in cdata into '&lt;'

12. Entity declaration for '<' and '&' in a DTD