Subject: Re: [xsl] Troublshooting XSLT replace() From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 03 Dec 2013 16:12:57 +0000 |
I'm glad my last query produced some mirth. I've got another today.
The "Undate" and "Circa" modes do not work in the following stylesheet and I can't figure out why. Can someone please point out my errors?
Many thanks, Nathan
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" doctype-public="+//ISBN 1-931666-00-8//DTD ead.dtd (Encoded Archival Description (EAD) Version 2002)//EN" doctype-system="ead.dtd" indent="yes"/> <xsl:variable name="vAllowedSymbols" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -.'"/> <xsl:template match="* | processing-instruction() | comment()"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="*/text()"> <xsl:variable name="phase1"> <xsl:apply-templates select="." mode="Punctuation"/> </xsl:variable>
David<xsl:variable name="phase2"> <xsl:apply-templates select="$phase1" mode="Undate"/> </xsl:variable> <xsl:variable name="phase3"> <xsl:apply-templates select="$phase2" mode="Circa"/> </xsl:variable> <xsl:apply-templates select="$phase3" mode="Extent"/> </xsl:template> <xsl:template match="unittitle/text()[matches(., '^.*\p{P}$')] | unittitle/title/text()[matches(., '^.*\p{P}$')] | unitdate/text()[matches(., '^.*\p{P}$')]" mode="Punctuation"> <xsl:sequence select="replace(., '(^.*)\p{P}$', '$1')"/> </xsl:template> <xsl:template match="unitdate/text()" mode="Undate"> <xsl:sequence select="replace(., 'Undated','undated')"/> </xsl:template> <xsl:template match="unitdate/text()" mode="Circa"> <xsl:sequence select="replace(., 'Circa','circa')"/> </xsl:template> <xsl:template match="physdesc/extent/text()" mode="Extent"> <xsl:value-of select="translate(.,translate(., $vAllowedSymbols, ''),'')"/> </xsl:template> <xsl:template match="unittitle[not(string(.))]"> </xsl:template> </xsl:stylesheet>
________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Troublshooting XSLT replace(), Nathan Tallman | Thread | Re: [xsl] Troublshooting XSLT repla, Nathan Tallman |
Re: [xsl] Select All Except First a, David Carlisle | Date | Re: [xsl] Troublshooting XSLT repla, Nathan Tallman |
Month |