cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject Re: Convert escaped xml back to xml or SAX events
Date Mon, 03 Mar 2008 17:05:04 GMT
On Fri, 2008-02-29 at 07:53 -0800, dkropotova wrote:
> Dear all, 
> I am using SOLR to store my xml files, that have been xml-escaped beforehand
> (so that now they are simply treated as text). 

Did you see

> When a search is performed and results are back, I now would like to restore
> my “escaped” xml. I created a simple transformer, but now I'm stuck on how
> to solve my problem. I got all escaped xml in a field, but now I need to
> convert it to xml or SAX events. 

<xsl:template match="arr">
      <xsl:for-each select="str">
          <xsl:call-template name="unescapeEm">
            <xsl:with-param name="val" select="text()"/>
  <xsl:template name="unescapeEm">
    <xsl:param name="val" select="''"/>
    <xsl:variable name="preEm" select="substring-before($val, '&lt;')"/>
      <xsl:when test="$preEm or starts-with($val, '&lt;')">
        <xsl:variable name="insideEm"
        <xsl:value-of select="$preEm"/>
        <span class="palabrabuscada">
          <xsl:value-of select="substring($insideEm,
        <xsl:variable name="leftover"
          select="substring($val,string-length($insideEm) + 6)"/>
        <xsl:if test="$leftover">
          <xsl:call-template name="unescapeEm">
            <xsl:with-param name="val" select="$leftover"/>
        <xsl:value-of select="$val"/>

Hope that helps.


> I've searched, but couldn't find any method
> that would accept string and try to do something useful with it – like
> converting in SAX events or DOM objects.
> Does anyone have any tips how to solve this problem??
> Many thanks in advance,
> Dasha
Thorsten Scherler                       
Open Source Java                      consulting, training and solutions

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message