Re: [xsl] XSL template "namespace" problem

Subject: Re: [xsl] XSL template "namespace" problem
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Wed, 29 Mar 2006 13:12:00 -0600
>     This latter code actually creates a link that one can click on. From
> what I'm understanding, this type of structure, because its not well
> formed, is completely incompatible with XSLT, even thought xsltproc
> processes it properly and IE interprets it correctly.

No, Wendell advised you to figure out how things are working without
JavaScript because it's just one more thing that could be confusing,
no one saying it can't be done.  What can't be done is stuff like:

<a href="<xsl:value-of select='foo' />">some link</a>

That should not work in any XSLT processor because that means the
stylesheet is malformed (and hence not XML).

So the two ways to work around this is:

1) Use attribute value templates, lots of people mentioned this:
<a href="{foo}">some link</a>
If you need a relatively complex bit of xslt you can do something like

<xsl:variable name="bar"><!-- some really complex xslt stuff here
--></xsl:variable>
<a href="{$bar}">some link</a>

2) use the <xsl:attribute> element like you're doing.


Also remember that as long as you're not outputting "xml" concerns
about well-formed of the output doesn't matter.  (Since you can output
text, which could also not be well-formed xml output)  The issues
you're having is whether or not your stylesheet is well-formed.  Since
it's XML, it needs to be.


> I guess I'm a little
> confused why these browsers and processors are interpreting it if its
> technically illegal.

I'd be surprised to find any processor supporting this:
<a href="<xsl:value-of select='foo' />">some link</a>. If you can find
one, post a small test case sample and report the bug to the
developers.

Notice one of the points we're trying to get across is that the XSLT
has no magic knowledge of the JavaScript.  It's just generating text
from a tree reperesentation of the input XML.

Michael's point is that the javascript URL/URIs are not handled by all
HTML browsers and validators.  (In other words, he's talking about the
HTML page that is generated after running the transformation process).
 For example, my pocket pc browser used to have issues with one of the
online applications that did this all the time. There are better
techniques to do this, see websites like http://www.quirksmode.org.
(I also know some vague techniques for having an empty href string or
using css styles to mimic the look of a link.  Been a while since I've
done any of those)  Getting into too much detail about something
that's really HTML and JavaScript design is off topic for this list.


Jon Gorman

Current Thread