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

Re: Troublshooting XSLT replace()

Subject: Re: Troublshooting XSLT replace()
From: Graydon <graydon@xxxxxxxxx>
Date: Tue, 3 Dec 2013 16:32:16 -0500
Re:  Troublshooting XSLT replace()
On Tue, Dec 03, 2013 at 04:05:04PM -0500, Nathan Tallman scripsit:
> I spoke to early, o omniscient one. <unittitle> can contain child
> nodes that are being stripped. I tried <xsl:copy-of> instead of
> <xsl:value-of>, but they're still being stripped.
> 
> The desired result is to keep all child nodes, remove trailing
> punctuation, replace Undated/undated, and replace Circa/circa.
> 
> Is there a way to do this with the identity template, without using *|node() ?

Kinda hard for it to be the identity template if you _don't_ use node()|@*.

<xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*" />
        </xsl:copy>
</xsl:template>
<xsl:template match="text()[ancestor::unittittle]">
    <xsl:value-of
        select="replace(replace(replace(.,'\p{P}+$',''),'Undated','undated'),'Circa','circa')"
         />
</xsl:template>

I'd be tempted to use "lower()" instead of the outer two replaces if you know you don't need to keep some other upper-case letters.

-- Graydon, who thinks there's a general rule with XSLT; if your code is turning into a vast tentacular mass of cases, there's probably something you missed.

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.