xsl-list
[Top] [All Lists]

RE: [xsl] string-replace AND apply-templates

2007-03-19 04:41:26
Sounds like a candidate for a two-pass transformation. In the first pass do:

<xsl:template match="tei:unclear//text()">
   <xsl:value-of select="replace(., &quot;()&quot;,&quot;
$1&combdotbl;&quot;)"/>
</xsl:template>

together with an identity template

<xsl:template match="*">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

In the second pass do whatever other processing you have to do.

Alternatively if this is the only processing you do on text nodes, just make
sure that all other templates for elements process the contained text using
xsl:apply-templates rather than xsl:value-of.

Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: Florian Grammel [mailto:grammel(_at_)gmx(_dot_)net] 
Sent: 19 March 2007 10:46
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] string-replace AND apply-templates

I don't have much experience with xsl, so there's a good 
chance that this question is trivial, but I'm just not getting it:

In TEI-ish xml we use <unclear> to tag insecure readings.
The tradition for printed editions says, that every unclear 
letter is rendered with a dot below.

Using XSLT 2 I can use RegEx to do this:

     <xsl:template match="tei:unclear">
         <xsl:copy>
             <xsl:value-of
                 select="replace(., &quot;()&quot;,&quot; 
$1&combdotbl;&quot;)"/>
         </xsl:copy>
     </xsl:template>


This works fine, but results in, that all possible markup inside the  
<unclear>-tags is lost. I guess it would be a solution to call this  
little template inside every other processing instruction, but as  
<unclear> is allowed on virtually every level of the xml, this is  
going to be a mess...

So I'm looking for a way to do the search-replace and get the code  
inside processed by the rest of the stylesheet nevertheless.
A sort of replace-instruction, that leaves tagging untouched and  
passes the result on to <xsl:apply-templates/>



Thanks in advance for your help!

Florian Grammel.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>