[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
andrew welch wrote:
<xsl:function name="f:replace-all">
<xsl:param name="input" as="xs:string"/>
<xsl:param name="words-to-replace" as="xs:string*"/>
<xsl:param name="replacement" as="xs:string*"/>
<xsl:sequence select="if (exists($words-to-replace)) then f:replace-all(replace($input, $words-to-replace[1], $replacement[1]),remove($words-to-replace,1),remove($replacement,1)) else $input"/>
</xsl:function>
<xsl:output method="xml" encoding="UTF-8" use-character-maps="brillMaps"/>
<xsl:template match="/">
<xsl:variable name="str" select="'Ά & test test the quick brown fox textc̲h̲k̲text test test the quick brown fox'"/>
<xsl:variable name="replacementStr" as="xs:string*" select="$entityTable/search[matches($str,.)]/following-sibling::replace/concat('<entity name="',.,'"/>')"/>
<test>
<xsl:value-of select="f:replace-all($str,$entityTable/search[matches($str,.)],$replacementStr)"/>
</test>
</xsl:template>
Wherein, i have a character map with this values:
Re: [xsl] Problem with ampersands
Subject: Re: [xsl] Problem with ampersands From: Jeff Sese <jsese@xxxxxxxxxxxx> Date: Wed, 27 Sep 2006 10:06:22 +0800 |
andrew welch wrote:
This would probably the best way to go with this problem. However how do i go about replacing all the occurrences of the entity equivalent with an element? Is this method the right approach?If you really must deliver XML with the entities in place I would suggest using a placeholder element (eg <entityA/>) to represent it in the output and the post process the result with a suitable language to replace the placeholder elements with the entity references.
<xsl:function name="f:replace-all">
<xsl:param name="input" as="xs:string"/>
<xsl:param name="words-to-replace" as="xs:string*"/>
<xsl:param name="replacement" as="xs:string*"/>
<xsl:sequence select="if (exists($words-to-replace)) then f:replace-all(replace($input, $words-to-replace[1], $replacement[1]),remove($words-to-replace,1),remove($replacement,1)) else $input"/>
</xsl:function>
<xsl:output method="xml" encoding="UTF-8" use-character-maps="brillMaps"/>
<xsl:template match="/">
<xsl:variable name="str" select="'Ά & test test the quick brown fox textc̲h̲k̲text test test the quick brown fox'"/>
<xsl:variable name="replacementStr" as="xs:string*" select="$entityTable/search[matches($str,.)]/following-sibling::replace/concat('<entity name="',.,'"/>')"/>
<test>
<xsl:value-of select="f:replace-all($str,$entityTable/search[matches($str,.)],$replacementStr)"/>
</test>
</xsl:template>
Wherein, i have a character map with this values:
<xsl:output-character string="<" character="<"/> <xsl:output-character string=">" character=">"/>
Thanks, -- Jeff
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem with ampersands, Rashmi Rubdi | Thread | [xsl] processing text nodes one cha, Marie Bilde Rasmusse |
[xsl] Re: processing text nodes one, Dimitre Novatchev | Date | [xsl] Break output into files based, Thangavelu Srinivasa |
Month |
Keywords