[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|