RE: [xsl] String manipulations with quotes

Subject: RE: [xsl] String manipulations with quotes
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 10 Apr 2003 18:54:54 -0400
Hi again Betty,

At 06:21 PM 4/10/2003, you wrote:
I don't have control over the authoring.  The quotes are already
embedded in the file.

If the XML file has


<text>"Oh foo!" said Tonya, as she looked at her list of warnings.</text>

and you say

<xsl:template match="text">
  <xsl:value-of select="translate(.,'&quot;','#')"/>
</xsl:template>

you should get

#Oh foo!# said Tonya, as she looked at her list of warnings.

(But note you can't say translate(.,'&quot;','&apos;'), since once it is parsed the stylesheet processor still chokes on translate(.,'&quot;',''') -- in a case like that you have to resort to binding the problem character to a variable.)

The entity is so the *stylesheet* can be parsed; it still represents the character literal it represents.

But in your case I'd simply try:

<xsl:variable name="name1">
     <xsl:value-of select="substring-after($definition, '&quot;')"/>
</xsl:variable>
<xsl:variable name="name2">
     <xsl:value-of select="substring-before($name1,  '&quot;')"/>
</xsl:variable>

The parser reports the values of the select attributes as, e.g.

substring-after($definition, '"')

which should be fine.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


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



Current Thread