xsl-list
[Top] [All Lists]

Re: Modify acronym replace "function"

2005-11-25 00:13:34
Good morning, good evening and hello!

I got it.

Thanks to all!!!

Cheers
Sven

Here my code:

<xsl:template name="replace-acronyms">
        <xsl:param name="acronyms"
select="document('')/xsl:stylesheet/xsl:template[(_at_)name='acro']/acronyms/acronym"
/>
        <xsl:param name="string" />
        <xsl:choose>
                <xsl:when test="not($acronyms)">
                        <xsl:value-of select="$string" />
                </xsl:when>
                <xsl:when test="not(string($string))" />
                <xsl:otherwise>
                        <xsl:variable name="acronym" 
select="$acronyms[1]/@acronym" />
                        <xsl:choose>
                                <xsl:when test="contains($string, $acronym)">
                                        <xsl:variable name="before" 
select="substring-before($string,
$acronym)" />
                                        <xsl:variable name="after" 
select="substring-after($string,
$acronym)" />
                                        <xsl:call-template 
name="replace-acronyms">
                                                <xsl:with-param name="string" 
select="$before" />
                                                <xsl:with-param name="acronyms" 
select="$acronyms[position() >  1]" />
                                        </xsl:call-template>
                                        <xsl:value-of select="$acronyms[1]"/>
                                        <xsl:call-template 
name="replace-acronyms">
                                                <xsl:with-param name="string" 
select="$after" />
                                                <xsl:with-param name="acronyms" 
select="$acronyms" />
                                        </xsl:call-template>
                                </xsl:when>
                        <xsl:otherwise>
                        <xsl:call-template name="replace-acronyms">
                                <xsl:with-param name="string" select="$string" 
/>
                                        <xsl:with-param name="acronyms" 
select="$acronyms[position() >  1]" />
                                </xsl:call-template>
                        </xsl:otherwise>
                </xsl:choose>
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>

<xsl:template name="acro">
<acronyms>
        <acronym acronym="vorbedingung">PRECONDITION</acronym>
        <acronym acronym="Vorbedingung">PRECONDITION</acronym>
        <acronym acronym="VORBEDINGUNG">PRECONDITION</acronym>
</acronyms>
</xsl:template>



Ragulf Pickaxe schrieb:
<xsl:param name="acronyms"
select="document('')/xsl:stylesheet/xsl:template[(_at_)name='acro']/acronyms"
/>

   <xsl:variable name="acronym" select="$acronyms[1]/@acronym" />

Your variable would have to look like this "..]/aconyms/acronym"


I meant param here (instead of variable). But you can change either.

Ragulf Pickaxe :-)

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