xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David_N_Bert...@lotus.com
Subject Re: Inverse of -ESCAPE parameter with testXSLT
Date Wed, 09 May 2001 14:55:24 GMT

Mark Jordan wrote:
> Hi,
>
> How do I tell testXSLT _not_ to escape certain characters? For example, I
> have a source document
>
> <FAQ ID="75">
> <QUESTION>How do I access electronic journals?</QUESTION>
> <ANSWER>
> <![CDATA[
> Electronic journals to which SFU Library subscribes are accessible
through
> our <a href="http://mercury.lib.sfu.ca/cgi-bin/ejournals/
> EJDB?Display=BrowseForm">Electronic Journals Database</a> (EJDB). See the
> "About" link at the EJDB for more information.
> ]]>
> </ANSWER>
> </FAQ>

Well, if you're going to put markup in a CDATA section, you are on your
own.  This is a common problem when you try to generate elements in the
result tree using CDATA and xsl:value-of.  Why don't you let the processor
generate the elements?  You could use xsl:element, or just copy elements
directly from the source tree.  This would require a slightly different
source document, so it will only work if you have control over the format.
For example:

source xml:

   <FAQ ID="75">
   <QUESTION>How do I access electronic journals?</QUESTION>
   <ANSWER>

   Electronic journals to which SFU Library subscribes are accessible
   through
   our <a href
   ="http://mercury.lib.sfu.ca/cgi-bin/ejournals/EJDB?Display=BrowseForm">Electronic

   Journals Database</a> (EJDB). See the"About" link at the EJDB for more
   information.

   </ANSWER>
   </FAQ>

stylesheet:

   <?xml version="1.0"?>
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">

   <xsl:template match="FAQ">
   <html>
   <head><title><xsl:apply-templates select="QUESTION"/></title></head>
   <body><xsl:apply-templates select="ANSWER"/></body>
   </html>
   </xsl:template>

   <xsl:template match="QUESTION">
   <i><xsl:value-of select="."/></i>
   </xsl:template>

   <xsl:template match="ANSWER">
   <i><xsl:copy-of select="node()"/></i>
   </xsl:template>

   </xsl:stylesheet>

produces:

   <html>
   <head>
   <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>
   <i>How do I access electronic journals?</i>
   </title>
   </head>
   <body>
   <i>

   Electronic journals to which SFU Library subscribes are accessible
   through our <a href
   ="http://mercury.lib.sfu.ca/cgi-bin/ejournals/EJDB?Display=BrowseForm">Electronic

   Journals Database</a> (EJDB). See the"About" link at the EJDB for more
   information.

   </i>
   </body>
   </html>

If the wrapping looks strange, it's probably a result of my mail editor or
your reader.

Another common way to do this is to use xsl:text and
disable-output-escaping, but that is much less portable (processors are not
required to support it), and is still bending the rules.

By the way, this sort of question is more appropriate for the xalan mailing
list, or even better, the Mulberry XSL mailing list, which is the best
place for answers to XSL questions.  See:

   http://www.mulberrytech.com/xsl/xsl-list/index.html

Dave



---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message