[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL template "namespace" problem

Subject: Re: XSL template "namespace" problem
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Wed, 29 Mar 2006 09:27:40 -0600
xsl template namespace
On 3/29/06, Ian Bonnycastle <ibonny@xxxxxxxxxxxx> wrote:
> Hey everyone, I noticed that this XSL mailing list was pretty active, and
> I have a pretty confusing question regarding the xsl:template tag.

First, the quick answer.   If you're using embedded stylesheets, IE
doesn't support it (at least as of 2002 by a quick search of the
archives).  In fact, I'd be suprised if many processors supported it,
but I never use them and don't know of anyone who does.  For more
detailed comments, look below.

The question is confusing because it seems like you have several large
misconceptions of XML and XSLT. There's a lot of stuff in here that
just browsing through the past couple of weeks would help you.  For
starters, this is an open tag <xsl:template> and this is a closing tag
</xsl:template>.  You're talking about the xsl:template as an element,
not the tags that are use to mark the element.

>  It only seems to occur when the
> sections are broken up via xsl:template.

I have no idea what you're talking about here.  I think it's a warning
sign that there's some misunderstanding about how templates work.
Templates match certain node patterns and outputs the results of
processing the XSLT code within the template element.  Anything not in
a template is...well, usually a mistake.

>  Does this change the division's
> namespace at all?

Only if you change it manually.

>  When I use "xsltproc" to consolidate the XSLT into a
> "flat" XSL file, with no templates, and have the XML file use that XSL
> file directly, everything works perfectly.

Ok, I'm not sure what you mean by consolidate.  I'm quickly flipping
through the xsltproc docs and don't see anything.   Below I assume you
mean to say something like

When I use xsltproc to generate the HTML from my XSLT, it works fine.
Of course, if that's the case, I have no idea why you're reapplying
the "flat" file to the XML (this should blow up).  (Of course, I have
no idea what you mean about flat).

I'm hoping you're not abusing the term XSL file like I've seen a
couple people lately.  An xsl file is typically either the
styleheet/transform that takes in input xml and produces an output or
a generated output in the form of the XSL-FO specification.  Since
you're talking about HTML, I doubt you're generating the second.

XSLT is a language for converting XML to various output formats.  It's
not like javascript where it is embedded in an HTML page or XML page
to give it dynamic behavior.  It generates the page, then is finished.
 Think of it in the same manner as a language like PHP.  Once the page
is generated you can't go and call a php function like you would a
JavaScript function.  I'm not sure if there's some bad tutorial out
there giving the impression that XSLT is more akin to JavaScript or
that the generated outputs are also "XSL pages".


> As an example (in the templated XSL file):
>
> <SCRIPT>
>     function Toggle(p_ID)
>     {
>         { ... Javascript code to turn on the particular division "p_ID" and
turn off the rest ... }
>     }
> </SCRIPT>
>
> <xsl:template match="/rootnode/menuitems/item">
>      <A HREF="javascript:Toggle('<xsl:value-of select="fname"
/>')"><xsl:value-of select="name" /></A>

Wow, the past few weeks I've seen this posted at least half a dozen
times.  You say you're following it.  You can't have elements within
attributes.  Look at the archives for
http://www.w3.org/TR/xslt#attribute-value-templates.  I'm highly
surprised xsltproc didn't spit out an error about this.

Remember, XSLT is well-formed XML.

Also, I'd advise against playing around with embedded XSLT (I'm
guessing that's partially what you're doing) until you understand more
of XSLT.   First off, if you are doing embedded XSLT (hard to tell
from your example) it doesn't work in most browsers.

> The above code parses correctly via xsltproc

I highly doubt that due to the elements within attributes, but without
more info I can't be sure.  I don't deal a lot with the embedded
stylesheets so perhaps there is some bug there.

Honestly, I think you need to take a step back and get some tutorial
information on XSLT and try to have the stylesheet separate from the
xml docs..

Jon Gorman

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.