Re: XT and Text Nodes

Subject: Re: XT and Text Nodes
From: James Clark <jjc@xxxxxxxxxx>
Date: Sun, 31 Jan 1999 04:30:20 +0700
first-of-any() is true when the node is the first *element* sibling. Do
something like:

<xsl:template match="p[FS and not(text())]" priority="1"/><!-- eliminate
it -->

<xsl:template match="p">
  <xsl:apply-templates/>
</xsl:template>

"Bloebaum, Amy M." wrote:
> 
> I am attempting to eliminate all occurrences of the sequence <p><FS/></p>
> from the XML document below.
> 
> <?xml version="1.0" standalone="yes"?>
> <doc>
> <name><p><FS/>Foo</p></name>
> <info><p><FS/></p><p>This is<FS/> a test.</p></info>
> </doc>
> 
> If the <p> element contains any text, I want to preserve the element in the
> result tree.
> >From the XSL spec, I would expect 'Foo' to be a text node in the XML
> document tree and a child of element 'p'.
> However, given the following style sheet, XT drops all three paragraph
> elements from the result tree.
> Is this a problem with XT or did I miss something in the tree construction
> process description?   Is there a better way to do this?
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";
>                 indent-result="yes">
> 
> <xsl:template match="doc">
>   <HTML>
>   <xsl:apply-templates/>
>   </HTML>
> </xsl:template>
> 
> <xsl:template match="FS">
>   <xsl:text>&amp;nbsp;</xsl:text>
>   <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="*/p">
>   <xsl:choose>
>     <!-- Match when Forced Space FS is only child of paragraph element -->
>     <xsl:when test="./FS[first-of-any() and last-of-any()]">
>     </xsl:when>
>     <xsl:otherwise>
>       <P>
>       <xsl:apply-templates/>
>       </P>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> Amy Bloebaum
> Consulting Software Engineer
> LEXIS-NEXIS
> +1 937 865 6800
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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


Current Thread