Re: [xsl] selecting not(node()) not working as I expect it to

Subject: Re: [xsl] selecting not(node()) not working as I expect it to
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Mon, 27 Feb 2006 10:47:06 -0800
Perfect, thanks a lot Michael.


On 2/27/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> select="*" selects the element children only, you want select="node()"
which
> also selects the text nodes.
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: Spencer Tickner [mailto:spencertickner@xxxxxxxxx]
> > Sent: 27 February 2006 18:26
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject: [xsl] selecting not(node()) not working as I expect it to
> >
> > Hello everyone,
> >
> > For some reason (Monday perhaps) I'm having a very difficult time with
> > a very simple concept. I'm simply trying to apply all templates except
> > a node and then apply that node and it's children. I've done this
> > before with no issue,, now, well I'm having issues.
> >
> > xml
> >
> > <?xml version="1.0"?>
> > <root>
> >                               <para>This is a paragraph</para>
> >                               <para>This is a paragraph
> >                                       <list mark="bull">
> >                                               <listitem>This
> > is a list</listitem>
> >                                               <listitem>This
> > is a list</listitem>
> >                                       </list></para>
> >                               <para>This is another paragraph</para>
> > </root>
> >
> > xsl
> >
> > <?xml version='1.0'?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> >
> > <xsl:template match="/">
> >       <xsl:apply-templates/>
> > </xsl:template>
> >
> > <xsl:template match="para">
> >       <p><xsl:apply-templates select="*[not(self::list)]"/></p>
> >       <xsl:apply-templates select="list"/>
> > </xsl:template>
> > <xsl:template match="para/text()">
> >       <xsl:value-of select="."/>
> > </xsl:template>
> > <xsl:template match="list">
> > <ul>
> >       <xsl:apply-templates/>
> > </ul>
> > </xsl:template>
> > <xsl:template match="listitem">
> > <li><xsl:apply-templates/></li>
> > </xsl:template>
> >
> > expected output
> >
> > <p>This is a paragraph</p>
> > <p>This is a paragraph</p>
> > <ul>
> >   <li>This is a list</li>
> >   <li>This is a list</li>
> > </ul>
> > <p>This is another paragraph</p>
> >
> > what I'm getting
> >
> >                               <p/>
> >                               <p/><ul>
> >                                               <li>This is a list</li>
> >                                               <li>This is a list</li>
> >                                       </ul>
> >                               <p/>
> >
> > any thoughts?

Current Thread