cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovidiu Predescu <ovi...@cup.hp.com>
Subject Re: The trouble with money... well with '$' to be precise...
Date Thu, 27 Apr 2000 05:58:57 GMT
Hi,

On Wed, 26 Apr 2000 11:12:50 -0700, "Simon" <simon@viafone.com> wrote:

> I'm wondering if anyone else using Cocoon with WAP has encountered this
> problem...
> 
> I'm getting an XML data stream and its being converted via XSL to various
> other formats, including HTML and WML.  Unfortunately some of the XML
> elements contain a single '$' character in their text nodes and in WML '$'
> introduces one of those pesky WAP device variables.  So my WAP/WML browser
> sees them and croaks complaining about invalid variable names.  The way
> around this is normally to escape the '$' with another '$' to "$$".  However
> where to do that substitution...
> 
> BTW: Using the XML entity &# doesn't work, variable substitution by the WML
> browser is done after all XML parsing.
> 
> I can't fix the original data stream, because its not a bug in the data, its
> perfectly correct to have the '$' there, its a WML specific thing - so
> "fixing" the data stream would break my HTML output which does nothing
> special with that '$' or "$$".  And I can't do any fixes on the final output
> (in the WMLFormatter after XSLT) because that legitimately contains use of
> '$' for real variable accesses and there's no way to distinguish real ones
> introduced by my XSL transform and the bogus ones introduced by the "bad"
> input.
> 
> Therefore I conclude I'd have to introduce the escaping of any naked '$'
> chars in the data after the reading of the XML, but before sending it to the
> XSL transform.
> 
> Before I start bashing on Cocoon code I'm wondering if anyone tackled this
> problem already or has a better suggestion?

You can use the Xalan extension functions: this basically allows you to define
your own functions that you can call from your XSLT transformation. You can
then write something like this:

<xsl:template match="text">
  <xsl:value-of select="utils:escape_chars({.})"/>
</xsl:template>

In the above example I assume that the function you're writing is
'escape_chars' and belongs to the package 'utils'.

For more information on Xalan extensions, go to:

http://xml.apache.org/xalan/extensions.html


Ovidiu

--  
Ovidiu Predescu <ovidiu@cup.hp.com>
http://orion.nsr.hp.com/ (inside HP's firewall only)
http://www.geocities.com/SiliconValley/Monitor/7464/



Mime
View raw message