Re: transformToFragment with a node

Jonas Sicking <[email protected]>
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Message-ID <[email protected]>
Alex Iskold wrote:
> Hi all,
> 
> I am trying to do the following:
> 
> JavaScript
> 
>     var elements = xml.documentElement.childNodes;
>     for ( var i = start; i <= end ; i++ ) {
>         var fragment = xsltProcessor.transformToFragment( elements[i], 
> doc );
>         list.appendChild( fragment );
>     }
> 
> XSL
> 
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
> 
> <xsl:include href="common.xsl"/>
> 
> <xsl:output method="xml"/>
> 
> <xsl:template match="/">
>      <vbox>
>     <xsl:value-of select="name(.)"/>
>     </vbox>
> </xsl>
> 
> Basically, I am looping through and applying stylesheet to invididual nodes.
> 
> But it does not seem to match, instead I get text clumped together in 
> return.
> I am declaring the XUL namespace so I am not sure what is wrong.

Your match expression match="/" only matches root nodes in the document 
you are transforming. However none of the nodes you are passing in are 
root nodes, but rather elements in the middle of the document. If you 
change your template to say

<xsl:template match="*">

it'll match any element that you pass in.

Hope that makes sense.

/ Jonas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.