andrew welch wrote:
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.
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?
<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
--~------------------------------------------------------------------
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>
--~--