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

Re: how to zap content between sibling elements?

Subject: Re: how to zap content between sibling elements?
From: "Helder da Rocha" <helder@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Aug 2002 17:05:10 -0300
a to zap com
Jay,

To get rid of the text between <k>s you need a XPath expression like:

    following-sibling::k and not(preceding-sibling::k)

in the context of the <p> element for the text before, and another one,
reversed for the text after. The code below solves the problem you posted:

    <xsl:template match="p">
        <p><xsl:copy-of select="*[not(self::k)]" />
        <xsl:apply-templates select="child::text()[following-sibling::k and
not(preceding-sibling::k)]" />
        <grp><xsl:apply-templates select="k" /></grp>
        <xsl:value-of select="following-sibling::text()" />
        <xsl:apply-templates select="child::text()[preceding-sibling::k and
not(following-sibling::k)]" /></p>
    </xsl:template>

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

Helder.

--
Helder da Rocha (helder@xxxxxxxxxxxxxxxx)
Web Consultant
www.argonavis.com.br
São Paulo, Brazil
+55 (11) 9291 0567

----- Original Message -----
From: "Jay Han" <hjhjjj@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, August 28, 2002 3:01 PM
Subject:  how to zap content between sibling elements?


> Hello all,
>
> I have a few siblings that I need to group together like this:
>
> original:
> <p> <!-- maybe some other element other than 'k' -->
> foo
>    <k>A</k> bar <k>B</k> baz <k>C</k>
> quux and more stuff
> </p>
>
> goal:
> <p>
> foo
>    <grp><k>A</k><k>B</k><k>C</k></grp>
> quux and more stuff
> </p>
>
> I can do the grouping  but I am having difficulties zapping 'bar'
> and 'baz' between <k>'s.  Currently I get:
> <p>
> foo
>    <grp><k>A</k><k>B</k><k>C</k></grp> bar baz
> quux and more stuff
> </p>
> I think I need a condition to my default copying template
> to handle the case of "when in-between <k>'s zap the content".
> What combination of axes and predicates can I use to express
> this condition?  Any hint or suggestion would be appreciated.
>
> thanks,
>
> -jay
>
>
> =====
> jhan@xxxxxxx
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
>
>  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.