This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: comment() node test


Evan --

Most likely you have whitespace text nodes between the element nodes and
the preceding comment.  Try substituting this for your first for-each
below and see what happens:

 <xsl:for-each select="element/../node()">
   <childnode><xsl:value-of select="."/></childnode>
 </xsl:for-each>

This should show you if the comment node does, indeed, immediately
preceded the element node.

Gary


Evan Lenz wrote:
> 
> I'm trying to display the value of the previous sibling if it is a comment.
> What's wrong with my XPath expression?  It won't display anything.
> 
> <xsl:for-each select="element">
>   <xsl:value-of select="preceding-sibling::node()[1][self::comment()]"/>
> </xsl:for-each>
> 
> I've confirmed that the parser I'm using passes comments to the XSLT
> processor (Instant Saxon), as the comment() node test works in other cases,
> such as the following:
> 
> <xsl:for-each select="comment()">
>   <xsl:value-of select="."/>
> </xsl:for-each>
> 
> Thanks,
> 
> Evan Lenz
> elenz@xyzfind.com


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]