[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] XPath query syntax


Subject: RE: [xsl] XPath query syntax
From: omprakash.v@xxxxxxxxxxxxx
Date: Thu, 19 May 2005 09:32:30 +0530

Hi,
    Here's another variation.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

 <xsl:template match="/">

 <xsl:apply-templates select="*"/>

</xsl:template>

 <xsl:template match="br">
<xsl:text>&#xa;</xsl:text>
</xsl:template>

 <xsl:template match="text()[not(normalize-space(.) = '')]">

<line>
<xsl:value-of select="normalize-space(.)"/>
</line>

</xsl:template>
</xsl:stylesheet>

Cheers,
Omprakash.V







                    "Aron Bock"
                    <aronbock@hot        To:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
                    mail.com>            cc:     (bcc: omprakash.v/Polaris)
                                         Subject:     RE: [xsl] XPath query
syntax
                    05/19/2005
                    04:54 AM
                    Please
                    respond to
                    xsl-list






Jon, some variant of this should work.  You may also want to use
normalize-space().

<?xml version="1.0" encoding="iso8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml"/>

    <xsl:template match="/">
        <xsl:for-each select="/textarea/node()[name() != 'br']">
            <line><xsl:copy-of select="."/></line>
        </xsl:for-each>
           </xsl:template>

</xsl:stylesheet>


>From: jpk <jopaki@xxxxxxxxx>
>I have source XML:
>
><textarea>
>   line 1<br/>
>   line 2<br/>
>   line 3<br/>
>   line 4<br/>
></textarea>
>
>How do I query for each of the line texts?  That is, I
>need to get each text [node] that preceeds all <br>
>tags.

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/






This e-Mail may contain proprietary and confidential information and is sent
for the intended recipient(s) only.
If by an addressing or transmission error this mail has been misdirected to
you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction,
dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its
attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in


Current Thread
Keywords