xsl-list
[Top] [All Lists]

Re: [xsl] Moving or removing a period

2010-05-18 14:20:18
<xsl:template match="text()[preceding-sibling::*[1]/self::link/prompt]">
  <xsl:value-of select="replace(., '^\.', '')"/>
</xsl:template>

On 18.05.2010 21:05, Flanders, Charles E (US SSA) wrote:
I need some help moving a period from one context to another. I can identify 
where period needs to be inserted but I can't get rid of the existing period.

Here's what a I have so far

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
       xmlns:xs="http://www.w3.org/2001/XMLSchema";
       exclude-result-prefixes="xs"
       version="2.0">
        <xsl:include href="copy.xsl"/>
        
        <xsl:template match="prompt">
                <xsl:if test="parent::link/following-sibling::text() ='.'">
                        <prompt>
                                <xsl:value-of select="."/><xsl:text>.</xsl:text>
                        </prompt>
                </xsl:if>
        </xsl:template>

A snippet of the pertinent XML looks something like this: (there's a whole lot more to 
this document, hence the "copy.xsl" include).

<para>
<link linkaction="prompt" linktype="goto" xlink:href="IETM://M00206" 
xmlns:xlink="http://www.w3.org/1999/xlink"; xreftype="wp">
<prompt>This is the content stuff</prompt>
</link>.
</para>

I can get the period into the<prompt>  element but I can't seem to find a good way to eliminate the period after 
the<link>  end tag. I cannot perform a simple search and replace because there are cases when a<link>  element 
does NOT have a child<prompt>  element, so that period needs to remain. I only want to eliminate "." 
when<link>  contains a child<prompt>.

The parent of<link>  is usually either<para>  or<trim.para>.



C Flanders


--~------------------------------------------------------------------
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>