[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Problem with ampersands
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|