xsl-list
[Top] [All Lists]

Re: Replacing double quotes with XSLT

2003-09-22 22:19:04
This is trivial using FXSL:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:testmap="testmap"
exclude-result-prefixes="testmap"

   <xsl:import href="str-dvc-map.xsl"/>

    <xsl:variable name="vQ">"</xsl:variable>

   <!-- to be applied on any xml source -->

   <xsl:output omit-xml-declaration="yes" indent="yes"/>

   <xsl:template match="/">
     <xsl:variable name="vTestMap" select="document('')/*/testmap:*[1]"/>
     <xsl:call-template name="str-map">
       <xsl:with-param name="pFun" select="$vTestMap"/>
       <xsl:with-param name="pStr" select="concat('abc', $vQ, 'def')"/>
     </xsl:call-template>
   </xsl:template>

    <testmap:testmap/>
    <xsl:template name="doubleQuote" match="testmap:*">
      <xsl:param name="arg1"/>
      <xsl:value-of select="$arg1"/>

      <xsl:if test="$arg1 = $vQ">"</xsl:if>
    </xsl:template>

</xsl:stylesheet>

When the above transformation is performed (on arbitrary source.xml -- not
used), the wanted result is produced:

abc""def



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



"James Paul" <jpaul(_at_)quadrem(_dot_)com> wrote in message
news:F78AE312483A2A46B76BF4D2D4842A65021B5B2E(_at_)qddalex01(_dot_)quadrem(_dot_)com(_dot_)(_dot_)(_dot_)
I'm trying to replace " within a string in XSLT and replace it with ""
but I'm not having any luck.

Does NOT work

<xsl:element name = "OrganizationCode">
<xsl:text>"</xsl:text>
<xsl:value-of select =
"translate(../@OrganizationCode,'\"','\"\"'"/>
<xsl:text>"</xsl:text>
</xsl:element>

Does NOT work

<xsl:element name = "OrganizationCode">
<xsl:text>"</xsl:text>
<xsl:value-of select =
"translate(../@OrganizationCode,'&#x22','&#x22&#x22'"/>
<xsl:text>"</xsl:text>
</xsl:element>

Does anyone have any suggestions ???

Thanks

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list