[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem with ampersands

Subject: Re: Problem with ampersands
From: Jeff Sese <jsese@xxxxxxxxxxxx>
Date: Wed, 27 Sep 2006 10:06:22 +0800
xslt output replace
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="'&#x0386; &amp; test test the quick brown fox text&#x0063;&#x0332;&#x0068;&#x0332;&#x006B;&#x0332;text test test the quick brown fox'"/>
<xsl:variable name="replacementStr" as="xs:string*" select="$entityTable/search[matches($str,.)]/following-sibling::replace/concat('&#x3c;entity name=&#x22;',.,'&#x22;/&#x3e;')"/>
<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="&#x3c;" character="&#x3c;"/>
<xsl:output-character string="&#x3e;" character="&#x3e;"/>

Thanks,
-- Jeff

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.