[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
amy bloebaum
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.