[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: Nathan Tallman <ntallman@xxxxxxxxx>
Date: Tue, 3 Dec 2013 11:52:01 -0500
Re:  Troublshooting XSLT replace()
David,

I've changed the root node in the master template to match on unitdate
and unittitle, so that I could match on unitdate/text() and
unittitle/text() in my mode templates, but it's stripping the
element's and just outputting text. I tried matching on
unitdate/text() and unittitle/text() (in the master template) but that
didn't work either, presumable because I was selecting a node of text,
so no node selection would work.

Could you make a suggestion to change my master template match and
mode template match?

Thanks,
Nathan


On Tue, Dec 3, 2013 at 11:12 AM, David Carlisle <davidc@xxxxxxxxx> wrote:
> On 03/12/2013 15:52, Nathan Tallman wrote:
>>
>> 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>
>
>
>
> so $phase1 is a root node with a single text child, being the result of the
> regexp replace?
>
> You might have done
>   <xsl:variable name="phase1" select="replace(., '(^.*)\p{P}$', '$1')"/>
> which would have been clearer if that is the only template, but then $phase1
> would be a string/
>
>
> so this
>
>   <xsl:apply-templates select="$phase1" mode="Undate"/>
> applies templates to a / node but the only template you have in that mode is
> unitdate/text() which never matches as, as noted above
> you have no element nodes, just  / with child a text node.
>
>
>
>
>>          <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>
>>
> David
>
>
>
> ________________________________________________________________________
> 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.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________

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.