You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sébastien Geindre <se...@meteo.fr> on 2010/05/17 12:00:30 UTC
Re: How to transform XML-URL-parameters a into a parse-able XML in
a pipeline ?
The result of
http://localhost:8888/fase3/foo?filter1=<a><b/><c/></a>&filter2=<root><a>SomeText</a></root>
is > RESULT:
> -------------
> <Request>
> <Parameters>
> <Parameter>
> <Name>filter2</Name>
> <Value><root><a>SomeText</a></root></Value>
> </Parameter>
> <Parameter>
> <Name>filter1</Name>
> <Value><a><b/><c/></a></Value>
> </Parameter>
> </Parameters>
> </Request>
but this result do not seem to be parsable, if you try to get <a> node
for instance....
<xsl:template match="/">
<root>
<xsl:apply-templates/>
</root>
</xsl:template>
<xsl:template match="a">
<debug><xsl:copy-of select="."/></debug>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|*|text()"/>
</xsl:copy>
</xsl:template>
it gives :
<root>
<Request xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
<Parameters>
<Parameter>
<Name>typeName</Name>
<Value>toto</Value>
</Parameter>
<Parameter>
<Name>request</Name>
<Value>GetFeature2</Value>
</Parameter>
<Parameter>
<Name>filter1</Name>
<Value><a><b/><c/></a></Value>
</Parameter>
<Parameter>
<Name>filter2</Name>
<Value><root><a>SomeText</a></root></Value>
</Parameter>
</Parameters>
</Request>
</root>
On 12/05/2010 14:21, Robby Pelssers wrote:
> But keep in mind that the content of the<Value> tag will be a string... in case you want to use the content as xml so you can transform it you might want to add an extra transformer in your pipeline.
> The only problem is you have to make sure that the values contain valid xml snippets of course.
>
>
> <map:match pattern="foo">
> <map:generate src="request/request.jx" type="jx"/>
> <map:transform src="value2xml.xslt"/>
> <map:serialize type="xml"/>
> </map:match>
>
>
> value2xml.xslt:
> --------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!--
> Author: Robby Pelssers
> -->
>
> <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
>
> <xsl:template match="/">
> <xsl:apply-templates/>
> </xsl:template>
>
> <xsl:template match="Value">
> <Value>
> <xsl:value-of select="." disable-output-escaping="yes"/>
> </Value>
> </xsl:template>
>
> <!-- copy all nodes and attributes which are not processed by one of available templates -->
> <xsl:template match="@*|node()">
> <xsl:copy>
> <xsl:apply-templates select="@*"/>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
>
>
> Cheers,
> Robby
>
>
> -----Original Message-----
> From: Robby Pelssers [mailto:robby.pelssers@ciber.com]
> Sent: Wednesday, May 12, 2010 2:11 PM
> To: users@cocoon.apache.org
> Subject: RE: How to transform XML-URL-parameters a into a parse-able XML in a pipeline ?
>
> Try this:
>
>
> <map:match pattern="foo">
> <map:generate src="request/request.jx" type="jx"/>
> <map:serialize type="xml"/>
> </map:match>
>
>
> Request.jx
> --------------
> <?xml version="1.0" encoding="UTF-8"?>
> <jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
> <Request>
> <Parameters>
> <jx:forEach var="parameterName" items="${cocoon.request.parameterNames}">
> <Parameter>
> <Name>${parameterName}</Name>
> <Value>${cocoon.request[parameterName]}</Value>
> </Parameter>
> </jx:forEach>
> </Parameters>
> </Request>
> </jx:template>
>
>
>
> http://localhost:8888/fase3/foo?filter1=<a><b/><c/></a>&filter2=<root><a>SomeText</a></root>
>
>
> RESULT:
> -------------
> <Request>
> <Parameters>
> <Parameter>
> <Name>filter2</Name>
> <Value><root><a>SomeText</a></root></Value>
> </Parameter>
> <Parameter>
> <Name>filter1</Name>
> <Value><a><b/><c/></a></Value>
> </Parameter>
> </Parameters>
> </Request>
>
>
> -----Original Message-----
> From: Sébastien Geindre [mailto:sebastien.geindre@meteo.fr]
> Sent: Wednesday, May 12, 2010 1:49 PM
> To: users@cocoon.apache.org
> Subject: How to transform XML-URL-parameters a into a parse-able XML in a pipeline ?
>
> Hi all,
>
>
> What i need to do is to transform http GET request into XML parse-able
> with cocoon 2.2
>
> an example :
>
> the request : http://host/foo?filter=<a><b/><c/></a>
>
> when i use<map:generate type="request">
> i have :
> <h:parameter name="filter">
> <h:value><a><b/><c/></a></h:value>
> </h:parameter>
>
> h:value is not parse-able..
>
> if i use<map:parameter name="xml" value="{request-param:filter}"/>
> i have got the same thing...
>
>
> any help ?
>
> thanks!
> Sébastien
>
>
>
> ---------------------------------------------------------------------
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org