xsl-list
[Top] [All Lists]

[xsl] XSL template "namespace" problem

2006-03-29 07:30:50
Hey everyone, I noticed that this XSL mailing list was pretty active, and I have a pretty confusing question regarding the xsl:template tag.

I'm attempting to modify DIV sections via Javascript so that they can be turned on and off... pretty standard. But, in order to setup my screen properly, I need to use xsl:template to recursively go down through the sections. When I do this, though, the Javascript I use to turn on and off the DIV sections suddenly can't see the sections anymore. It claims (well, the Javascript console on the browser I use complains) that the section I'm attempting to access does not exist. It only seems to occur when the sections are broken up via xsl:template. Does this change the division's namespace at all? 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.

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>

    <DIV ID='<xsl:value-of select="fname" />' STYLE="display:none">
        <xsl:value-of select="desc"/>
    </DIV>
</xsl:template>

(Above, its assumed that each "item" in the XML file has 3 parts, the "name", or link name, the "fname" or proper calling name, and the "desc" or the text within the division to display when clicked.)

The above code parses correctly via xsltproc, but when put into IE, IE complains that "Toggle" can't find the p_ID of item "itemone", if that, for example, is the fname of one of the items in the XML file.

Whats going on here? If I parse out the above with xsltproc and save it to a file, IE is perfectly happy and can find everything fine.

Ian

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--