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

Re: not matching empty text nodes.

Subject: Re: not matching empty text nodes.
From: Terence <tk.lists@xxxxxxxxxxx>
Date: Sun, 09 Feb 2003 13:41:30 +1100
xsl match empty text
Ross Ken wrote:

Try

xsl:template match="/album/photos/photo/caption[text()!='']"

This works very well :-)

The only problem is, some of the non-empty text nodes are nothing but
whitespace.

to fix the problem I did this.

xsl:template match="photo/*[text()!=''][count(*)=0]"

That's because all the text nodes I want to capture don't have any other
sub-elements (ie. it's plain text, not markup).

I tried using <xsl:strip-space elements="*" />
but it seemed to have no effect on the sablotron processor.


and


<xsl:template match="/album/photos/photo/*[text()!='']">
   <tr valign="top">
       <td class="label" align="right"><xsl:value-of select="name()"/>:</td>
       <td class="caption"><xsl:value-of select="." /></td>
   </tr>
</xsl:template>

This works a treat :-)

Thanks. Most helpfull indeed.

I've made several modifications based on a similar thing.

    <xsl:template match="photo/*[text()!=''][count(*)=0]">
        <tr valign="top">
            <td class="label" align="right"><xsl:value-of
select="name()"/>:</td>
            <td class="{name()}"><xsl:value-of select="." /></td>
        </tr>
    </xsl:template>

    <xsl:template match="photo/*[@name!='']">
        <tr valign="top">
            <td class="label" align="right"><xsl:value-of
select="name()"/>:</td>
            <td class="{name()}"><xsl:value-of select="@name" /></td>
        </tr>
    </xsl:template>

    <xsl:template match="photo/*[@year!='']">
        <tr valign="top">
            <td class="label" align="right"><xsl:value-of
select="name()"/>:</td>
            <td class="{name()}">
                <xsl:value-of select="@day" />/<xsl:value-of
select="@month" />/<xsl:value-of select="@year" /> -
                <xsl:value-of select="@hour" />:<xsl:value-of
select="@min" />
            </td>
        </tr>
    </xsl:template>

This has reduced the size of my sheet signifigantly and there is less
modification in the event of a schema change.




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.