cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel F. Jones" <...@cs.utexas.edu>
Subject Re: The trouble with money... well with '$' to be precise...
Date Wed, 26 Apr 2000 20:29:44 GMT
This might not be the most efficient solution, but it works:

  <xsl:template match="attribute">
      <xsl:value-of select="@name"/>=<xsl:apply-templates select="text()"/>
  </xsl:template>
  
  
  <xsl:template match="text()" name="text">
    <xsl:param name="text" select="."/>
    <xsl:choose>
      <xsl:when test="contains($text,'$')">
        <xsl:value-of select="substring-before($text,'$')"/>
        <xsl:text>$$</xsl:text>
        <xsl:call-template name="text">
          <xsl:with-param name="text" select="substring-after($text,'$')"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


-Dan


On Wed, 26 Apr 2000, Simon 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?
> 
> Thanks,
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 
> 


Mime
View raw message