You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by dkropotova <Da...@semantico.com> on 2008/02/29 16:53:29 UTC
Convert escaped xml back to xml or SAX events
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).
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. 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
--
View this message in context: http://www.nabble.com/Convert-escaped-xml-back-to-xml-or-SAX-events-tp15761385p15761385.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Convert escaped xml back to xml or SAX events
Posted by Antonio Gallardo <ag...@agssa.net>.
Hi,
Hope this helps:
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/xml/StringXMLizable.html
Best Regards,
Antonio Gallardo.
dkropotova escribió:
> 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).
>
> 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. 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Convert escaped xml back to xml or SAX events
Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
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 http://wiki.apache.org/solr/SolrForrest?
>
> 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">
<p>
<xsl:call-template name="unescapeEm">
<xsl:with-param name="val" select="text()"/>
</xsl:call-template>
</p>
</xsl:for-each>
</xsl:template>
<xsl:template name="unescapeEm">
<xsl:param name="val" select="''"/>
<xsl:variable name="preEm" select="substring-before($val, '<')"/>
<xsl:choose>
<xsl:when test="$preEm or starts-with($val, '<')">
<xsl:variable name="insideEm"
select="substring-before($val,'</')"/>
<xsl:value-of select="$preEm"/>
<span class="palabrabuscada">
<xsl:value-of select="substring($insideEm,
string-length($preEm)+5)"/>
</span>
<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:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$val"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Hope that helps.
salu2
> 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 thorsten.at.apache.org
Open Source Java consulting, training and solutions
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Convert escaped xml back to xml or SAX events
Posted by warrell harries <wa...@googlemail.com>.
You could use Saxon e.g. :-
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/">
<xsl:template match="/">
<xsl:copy-of select="saxon:parse(XPathToYourXMLAsTextHere)"/>
</xsl:template>
</xsl:stylesheet>
On 29/02/2008, dkropotova <Da...@semantico.com> 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).
>
> 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. 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
>
> --
> View this message in context:
> http://www.nabble.com/Convert-escaped-xml-back-to-xml-or-SAX-events-tp15761385p15761385.html
> Sent from the Cocoon - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>