forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mansfield, Dave" <DMansfi...@gers.com>
Subject Minor problem: krysalis skin/jscript issue with quotes...
Date Wed, 08 Oct 2003 16:28:27 GMT
Hi!

FIRST OFF -- very cool stuff!  Finally getting the hang of using Cocoon/Forrest, and on a
mission to auto-publish Web pages from our internal CVS repository... I've been in lurk mode
with this mailing list as I learn the various pieces.. I'll be looking to contribute back
to the community..

Issue:  We continue to have a variety of file naming conventions, that include all kinds of
characters (e.g., double/single quotes, ampersands, etc.).  I've written a Java publishing
package that generates a 'site.xml' and 'tabs.xml' from a directives file. It basically pulls
in the directory structure and "beautifies" it (well, it's all in the eye of the beholder!).

(Side note:  I'd like to extend the ability of Forrest/Cocoon to auto-magically extract Microsoft-centric
info (title, subject, etc.).  I've written an extended directory generator that uses Apache's
POI to add custom MS-centric attributes into the XML stream; will be looking to customize
Forrest skins to take advantage of this.)

I'm playing around with customing skins, and like the expanding menu feature of the Krysalis
skins.  In doing so, I found that single quotes get in the way of the transformed "onclick=(SwitchMenu('{$tagid}')"
within the XSLT file:
 ./skins/krysalis-site/xslt/html/site2html.xsl

Solution:  Escape single quotes.  Requires adjusting two files:
 ./skins/krysalis-site/xslt/html/site2html.xsl
 ./skins/common/xslt/html/pathutils.xsl

In file "./skins/krysalis-site/xslt/html/site2html.xsl":

In the template "innermenuli", add new variable:

**** XSLT code ****
    <xsl:variable name="jstagid">
       <xsl:call-template name="escquote"><xsl:with-param name="path" select="string(concat($tagid,
$aQuote))"/></xsl:call-template>
    </xsl:variable>
**** XSLT ends ****

Then at the line in the template that says:

onclick="SwitchMenu('{$tagid}')

substitute $jstagid for $tagid.

In file "./skins/common/xslt/html/pathutils.xsl":

In global, add new variable:
**** XSLT code ****
<!--
  This variable assists with escaping single quotes in strings.  Must be
  a variable, as XML will translate '#x2c' into the actual quote BEFORE the
  XSLT processor can get to it.
-->
<xsl:variable name="aQuote">'</xsl:variable>
**** XSLT ends ****

Add new template:
**** XSLT code ****
<!-- Template to escape single quotes.  Useful when constructing strings
  that will be created in jscript strings.
Examples:
"fool's gold" -> "fool\'s gold"
-->
<xsl:template name="escquote">
  <xsl:param name="path"/>
  <xsl:variable name="preStr" select="substring-before($path,$aQuote)"/>
  <xsl:variable name="postStr" select="substring-after($path,$aQuote)"/>
  <xsl:if test="not($preStr) and not($postStr)"><xsl:value-of select="$path"/></xsl:if>
  <xsl:if test="$preStr"><xsl:value-of select="$preStr"/></xsl:if>
  <xsl:if test="string($postStr) and not($postStr=$aQuote)"><xsl:text>\'</xsl:text><xsl:call-template
name="escquote"><xsl:with-param name="path" select="$postStr"/></xsl:call-template></xsl:if>
</xsl:template>
**** XSLT ends ****


Dave Mansfield
Principal Engineer
Technology Group, GERS R&D     
GERS, INC.
10431 Wateridge Circle
San Diego, CA 92121

Mime
View raw message