cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geert Josten <Geert.Jos...@daidalos.nl>
Subject Re: parsing xml code [converting escaped tags?]
Date Tue, 01 Mar 2005 07:51:07 GMT
Hi Vlad, Derek, others,

I saw something like 'disable-output-escaping' in the XSL snippet in one of the earlier submits.

Note that the output unescaping only occurs when the output is actually serialized. In other
words, 
the unescaping is postponed until the file is actually written to file or serialized to a
stream in 
the http respons (or else).

You could write the escaped fragment to file using the disable-output-escaping feature to
get normal 
XML and reparse it as any other file source, but it might be easier to access you Cocoon site

through HTTP again (from within your Cocoon site), to access the XML you desire so much...

<map:match pattern="unescape/**">
   <map:generate src="cocoon:/{1}"/>
   <map:transform src="unescape-xml.xsl" /> <!-- the original XSL? -->
   <map:serialize type="xml" />
</map:match>

<map:match pattern="get-unescaped/**">
   <map:generate 
src="http:/{request:serverName}:{request:serverPort}{request:contextPath}{global:sitemapBaseURI}/unescape/{1}"/>
   <map:serialize type="xml" />
</map:match>

where sitemapBaseURI is defined as a local variable of the sitemap in which you put these
pipes and 
which contains the path from webapp to the sitemap in URI terms...

Though, the best solution would actually be, _not_ to escape your XML code altogether. But
I can't 
really tell how to do that.

Cheers,
Geert

Derek Hohls wrote:

> Vlad
> 
> I have never done this; I am still struggling with the htmlArea
> component that is used with Cocoon forms... it saves all the
> data as escaped tags (as per your example) and that makes
> it impossible to post-process... what Cocoon needs is a transformer
> that takes a file with escaped tags and converts them to valid XML.
> 
> Any takers to code this??
> 
> Derek
> 
> 
>>>>vlad@top.ee 2005/02/28 01:25:47 PM >>>
> 
> Derek,
> 
> that was very helpful. It would work if there wouldn't be one moment.
> I
> noticed that actually all the data in DB is in such format:
> 
> &lt;contact&gt;
>  &lt;name&gt;Chris&lt;/name&gt;
>  &lt;surname&gt;Lautre&lt;/surname&gt;
>  &lt;address&gt;Plomipuu 16&lt;/address&gt;
>  &lt;email&gt;clautre@datanet.ee&lt;/email&gt;
>  &lt;phone&gt;&lt;/phone&gt;
> &lt;/contact&gt;
> 
> Is it possible to convert it to the normal tags and then apply your
> method?
> 
> Vlad
> 
> "Derek Hohls" <DHohls@csir.co.za> wrote in message
> news:s223068b.097@cs-emo.csir.co.za...
> 
>>You may need to add in a namespace to the file below to
>>make it a valid XML file  e.g.
>>
>><pcomponentobjectOut
>>  xsi:type="ns2:DBConnection1_ComponentObjectUser"
>>  xmlns:xsi="http://apache.org/cocoon/xsi/1.0">
>>...
>>
>>Then the following works (under my Cocoon 2.1.5):
>>
>><?xml version="1.0"?>
>><xsl:stylesheet version="1.0"
>>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>>  xmlns:xsi="http://apache.org/cocoon/xsi/1.0"
>>  >
>>
>><xsl:template match="pcomponentobjectOut">
>> <xsl:apply-templates/>
>></xsl:template>
>>
>><xsl:template match="componentClob">
>> <xsl:apply-templates/>
>></xsl:template>
>>
>><xsl:template match="contact">
>>  <xsl:value-of select="surname"/>,<xsl:value-of select="name"/>
>></xsl:template>
>>
>><xsl:template match="*">
>></xsl:template>
>>
>></xsl:stylesheet>
>>
>>
>>HTH.
>>
>>
>>
>>>>>vlad@top.ee 2005/02/28 11:41:10 AM >>>
>>
>>Hi All,
>>
>>I have a web service, which returns me code like that:
>>
>>
> 
> --------------------------------------------------------------------------
> --
> 
>>--
>><pcomponentobjectOut
> 
> xsi:type="ns2:DBConnection1_ComponentObjectUser">
> 
>>  <componentClob xsi:type="xsd:string"><contact> <name>Chris</name>
>><surname>Lautre</surname> <address>Plomipuu 16</address>
>><email>clautre@datanet.ee</email> <phone></phone> </contact>
> 
> <contact>
> 
>><name>Vlad</name> <surname>Golodov</surname> <address>Paasiku
22 -
>>155</address> <email>vlad@top.ee</email> <phone>+37256639190</phone>
>></contact></componentClob>
>>  <componentId xsi:type="xsd:decimal">97</componentId>
>>  <componentName xsi:type="xsd:string">Address Book For
>>Other</componentName>
>>  <componentType xsi:type="xsd:string">ADDRESSBOOK</componentType>
>>  <dateCreated
>>xsi:type="xsd:dateTime">2005-02-21T11:46:50.000Z</dateCreated>
>>  <dateUpdated xsi:type="xsd:dateTime" xsi:nil="true" />
>>  <description xsi:type="xsd:string">New Address Book For
>>Other</description>
>>  <groupId xsi:type="xsd:decimal">11</groupId>
>>  <newPosts xsi:type="xsd:string" xsi:nil="true" />
>>  <ownerUserName xsi:type="xsd:string">clautre</ownerUserName>
>>  </pcomponentobjectOut>
>>
> --------------------------------------------------------------------------
> --
> 
>>--
>>
>>In xslt I need to parse componentClob and iterate through the
> 
> contact
> 
>>tags.
>>
>>That code gives me the content of the componentClob:
>>
>>
> 
> --------------------------------------------------------------------------
> --
> 
>>-
>><xsl:template match="*/return/pcomponentobjectOut">
>>  <xsl:value-of select="componentClob"
> 
> disable-output-escaping="yes"/>
> 
>></xsl:template>
>>
> --------------------------------------------------------------------------
> --
> 
>>-
>>
>>I was trying to iterate through the content of clob, but all was
>>vainly.
>>
>>
>>
>>
>>
> 
> ---------------------------------------------------------------------
> 
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
>>For additional commands, e-mail: users-help@cocoon.apache.org 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
> For additional commands, e-mail: users-help@cocoon.apache.org 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 

-- 
Geert.Josten@Daidalos.nl
IT-consultant at Daidalos BV, Zoetermeer (NL)

http://www.daidalos.nl/
tel:+31-(0)79-3316961
fax:+31-(0)79-3316464

GPG: 1024D/12DEBB50


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message