- From: James Clark <jjc@jclark.com>
- Date: Thu, 01 Jul 1999 19:44:51 +0700
- To: Jim Palmer <jpalmer@liberate.com>
- CC: xsl-editors@w3.org
The short answer is that your implementation's HTML 4.0 output writer
needs to be smarter and not escape & in attribute values when followed
by { (doing this is legal in HTML 4.0 but not in XML). Thanks for
pointing this out.
Jim Palmer wrote:
>
> All,
>
> First, let me state up front that I am an HI designer, not an
> engineer,
> so I just may have missed something here. I've posted this observation
> on several lists, and the answer I got back doesn't work. I've also
> read
> the latest draft, but can't seem to find a way to do this ion XSL, and
> I
> think it will be common for those of us doing content.
>
> A simplified set of sample files are included. I haven't tried this
> yet
> in lotus alphaworks xsl or XT because I want to avoid the java route
> right now; I am using ixslt from infoteria.
>
> Thanks
> --jp
>
> Goal: To generate a javascript entity in my output because yes, some
> attributes needs to be computed in the runtime context.
>
> Basic problem: I want to generate a real "&" in my output, not an html
> entity, e.g.:
>
> <body background="&{foo}" ... >
>
> Someone on the XSL list told me to do it like this in xsl:
>
> <body bacgkround="&{{foo}}" ... />
>
> But that yields:
>
> <body background="&{foo}" ... >
>
> in the output.
>
> Since the "&" is a general char for doing entities, this works if the
> & is in the main text of the HTML. But (my SWAG): in the special
> case of a tag attribute, the HTML entity gets parsed first and so the
> parser never sees it as a javascript entity (it's as if it would have
> to
> do two passes in that case)..
>
> But if I change the xsl to
>
> <body bacgkround="&{{foo}}" ... />
>
> I get this --no attribute at all -- and I don't know why:
>
> <body bacgkround ... />
>
> Can you explain what is happening here? Is there a way to get the pure
> "&" character in the output stream? In general, doesn't XSL provide an
> escape "take the following characters exactly as is" mode? If it does,
> iI found it extremely non-obvious.
>
> Sample files: Generate simple.html anyway you want from simple.xml +
> simple.xsl; the correct result is simpleCorrect.html (note that IE5
> doesn't seem to parse legal JS entities at all; works fine in
> Netscape).
>
> ---------------------------------------------------------------
> [Image]
>
> ---------------------------------------------------------------
> <?xml version="1.0"?>
> <error variant="normal">
>
> </error>
>
> ---------------------------------------------------------------
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
> xmlns="http://www.w3.org/TR/REC-html40
> "
> result-ns=""
> default-space="strip"
> indent-result="yes">
>
> <xsl:variable name="backgroundColor">#4f4f4f</xsl:variable>
> <xsl:variable name="textColor">#DDDDCC</xsl:variable>
> <xsl:variable name="linkColor">#3333BB</xsl:variable>
>
> <xsl:template match="/">
> <HTML>
>
> <HEAD>
> <TITLE>Example</TITLE>
>
> <SCRIPT>
> // imagine that this is really
> computed somehow in a function
> var background =
> "arrows_l.gif";
> </SCRIPT>
>
> </HEAD>
>
> <BODY background = "&{{background}};"
> bgcolor="{$backgroundColor}" text="{$textColor};"
> link="{$linkColor};">
>
> This is an example. If the javascript entity
> is seen, you will see a small
> arrow tiled as the background of this page.
>
> </BODY>
>
> </HTML>
> </xsl:template>
>
> </xsl:stylesheet>
>
> ---------------------------------------------------------------
> This is an example. If the javascript entity is seen, you will see a
> small arrow tiled as the background of this page.
Received on Thursday, 1 July 1999 08:47:06 UTC