|
Subject: Re: [xsl] Troublshooting XSLT replace() From: Graydon <graydon@xxxxxxxxx> Date: Tue, 3 Dec 2013 16:32:16 -0500 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Troublshooting XSLT repla, Nathan Tallman | Thread | Re: [xsl] Troublshooting XSLT repla, Nathan Tallman |
| Re: [xsl] Troublshooting XSLT repla, Nathan Tallman | Date | Re: [xsl] Select All Except First a, Matthew L. Avizinis |
| Month |