You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alexander Berezhnoy <al...@splc.ru> on 2005/06/01 15:11:24 UTC

XMLFileModule for a dynamic file.

Dear friends,
I've been looking for this feature for a week already, nobody and nowhere
can't give me a definite answer.

I want to extract data with XPath from an XML file whoes name depends on
request parameters.
The XMLFileModule is statically configured, so the file name is fixed.

Please, is it possible without writing my own module?

Thanks,
Alexander.


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


Re: XMLFileModule for a dynamic file.

Posted by Gerald Aichholzer <ga...@sbox.tugraz.at>.
Hello Alexander,

Alexander Berezhnoy wrote:
> Dear friends,
> I've been looking for this feature for a week already, nobody and nowhere
> can't give me a definite answer.
> 
> I want to extract data with XPath from an XML file whoes name depends on
> request parameters.
> The XMLFileModule is statically configured, so the file name is fixed.
> 
> Please, is it possible without writing my own module?
> 

I have had similar problems last week and have solved it with an
aggregator. A simplified version of my pipeline looks like this:

   <map:pipeline match="myapp/*/info.xml">

     <map:aggregate element="document">
       <map:part src="cocoon:/myapp/data/data.xml"/>
       <map:part src="cocoon:/myapp/data/data-{1}.xml"/>
     </map:aggregate>

     <map:transform type="xslt" src="cocoon:/stylesheets/info.xsl"/>

     <map:serialize type="xml"/>
   </map:pipeline>

The pipeline's first stage aggregates the base data with the xml file
(in my case its name is determined by the matcher). The result looks
like the following:

   <document>
     <!-- content of data.xml here -->
     <!-- content of data-{1}.xml here -->
   </document>

The next step is the transformation. For the stylesheet it looks like
everything is in one file (although in reality the content is generated
dynamically depending on the URI).

I can't say if my approach meets your requirements, too, but it fits
my needs perfectly.

HTH,
Gerald

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


Re: XMLFileModule for a dynamic file.

Posted by Alexander Berezhnoy <al...@splc.ru>.
Hi!
I've resolved the problem in the following manner:

<act type="xpath" src="{myfile}.xml">
    <parameter name="xmlns:myns" value="http://mynamespaceuri"/>
    <parameter name="model-parameter" value="xpathResult"/>
    <parameter name="return-type" value="string"/>
    <parameter name="xpath" value="string(//myns:tag[@attribute=value])"/>
   
    <... using the {xpathResult} variable ... >
</act>

The "xpath" action is written by myself. It applies the XPath expression 
to a file and returns the result into its object model.
I think this can be enough useful to include this action in the Cocoon.

Alexander.
//////////////////

>Alexander Berezhnoy wrote:
>  
>
>>Well, here is the usecase.
>>The mobile portal supports downloading binary resources for the various
>>handsets (that's implemented via the reader).
>>
>>The resources to be downloaded depend of the handsets' parameterers, which
>>are stored in  xml-file.
>>To pass the necessary params to the reader, I need to get them from xml by
>>their User-Agent (i.e. to apply an xpath).
>>
>>The case is complicated in that the handsets descriptions are stored to the
>>different files accorting to their mobile network(Various networks may have
>>different settings for some handsets).
>>    
>>
>
>sounds familiar to me :) Handling different handsets across different
>network operators with different MMSCs is worse than doing cross browser
>javascript !
>
>Unfortunately i don't see an easy solution. Did you look into the
>deliblock? It integrates UA Profiles and CCPP nicely with cocoon. Maybe
>this is a way out for you as you say the handset capabilities/parameters
>are stored in xml anyway.
>
>hth
>jorg
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>


-- 
Alexander Berezhnoy,
Chief Architect
SmartPhone Labs, LLC
http://www.smartphonelabs.com


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


Re: XMLFileModule for a dynamic file.

Posted by Jorg Heymans <jh...@domek.be>.
Alexander Berezhnoy wrote:
> Well, here is the usecase.
> The mobile portal supports downloading binary resources for the various
> handsets (that's implemented via the reader).
> 
> The resources to be downloaded depend of the handsets' parameterers, which
> are stored in  xml-file.
> To pass the necessary params to the reader, I need to get them from xml by
> their User-Agent (i.e. to apply an xpath).
> 
> The case is complicated in that the handsets descriptions are stored to the
> different files accorting to their mobile network(Various networks may have
> different settings for some handsets).

sounds familiar to me :) Handling different handsets across different
network operators with different MMSCs is worse than doing cross browser
javascript !

Unfortunately i don't see an easy solution. Did you look into the
deliblock? It integrates UA Profiles and CCPP nicely with cocoon. Maybe
this is a way out for you as you say the handset capabilities/parameters
are stored in xml anyway.

hth
jorg


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


Re: XMLFileModule for a dynamic file.

Posted by Upayavira <uv...@odoko.co.uk>.
Alexander Berezhnoy wrote:
> Well, here is the usecase.
> The mobile portal supports downloading binary resources for the various
> handsets (that's implemented via the reader).
> 
> The resources to be downloaded depend of the handsets' parameterers, which
> are stored in  xml-file.
> To pass the necessary params to the reader, I need to get them from xml by
> their User-Agent (i.e. to apply an xpath).
> 
> The case is complicated in that the handsets descriptions are stored to the
> different files accorting to their mobile network(Various networks may have
> different settings for some handsets).
> 
> So that's all.
> 
> Just now I've invented a solution: I can write a serializer instead of a
> reader and extract all data in xslt's. But that's more ugly, and very sad if
> the same is impossible with XMLFileModule.

Well, all I'd say is, if you can write yourself a serializer, why don't 
you write yourself an InputModule?

If the XMLFileModule doesn't do quite what you need it to, take its code 
and make one that does do what you want it to. And if it is generic 
enough, it might make sense as an extension/addition to Cocoon.

Make sense?

Regards, Upayavira

> Alexander.
> 
> //////////////////
> 
> ----- Original Message -----
> From: "Jorg Heymans" <jh...@domek.be>
> To: <us...@cocoon.apache.org>
> Sent: Wednesday, June 01, 2005 11:05 PM
> Subject: Re: XMLFileModule for a dynamic file.
> 
> 
> 
>>Alexander Berezhnoy wrote:
>>
>>>Plain XSLT won't help here.
>>>I need to extract the string and pass it as a param, say, to a reader.
>>>
>>
>>Well, TIMTOWTDI !
>>
>>Explain your usecase, maybe there is another way to achieve the same
> 
> result.
> 
>>Jorg
>>
>>
>>---------------------------------------------------------------------
>>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


Re: XMLFileModule for a dynamic file.

Posted by Alexander Berezhnoy <al...@splc.ru>.
Well, here is the usecase.
The mobile portal supports downloading binary resources for the various
handsets (that's implemented via the reader).

The resources to be downloaded depend of the handsets' parameterers, which
are stored in  xml-file.
To pass the necessary params to the reader, I need to get them from xml by
their User-Agent (i.e. to apply an xpath).

The case is complicated in that the handsets descriptions are stored to the
different files accorting to their mobile network(Various networks may have
different settings for some handsets).

So that's all.

Just now I've invented a solution: I can write a serializer instead of a
reader and extract all data in xslt's. But that's more ugly, and very sad if
the same is impossible with XMLFileModule.

Alexander.

//////////////////

----- Original Message -----
From: "Jorg Heymans" <jh...@domek.be>
To: <us...@cocoon.apache.org>
Sent: Wednesday, June 01, 2005 11:05 PM
Subject: Re: XMLFileModule for a dynamic file.


>
> Alexander Berezhnoy wrote:
> > Plain XSLT won't help here.
> > I need to extract the string and pass it as a param, say, to a reader.
> >
>
> Well, TIMTOWTDI !
>
> Explain your usecase, maybe there is another way to achieve the same
result.
>
> Jorg
>
>
> ---------------------------------------------------------------------
> 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


Re: XMLFileModule for a dynamic file.

Posted by Jorg Heymans <jh...@domek.be>.
Alexander Berezhnoy wrote:
> Plain XSLT won't help here.
> I need to extract the string and pass it as a param, say, to a reader.
> 

Well, TIMTOWTDI !

Explain your usecase, maybe there is another way to achieve the same result.

Jorg


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


Re: XMLFileModule for a dynamic file.

Posted by Alexander Berezhnoy <al...@splc.ru>.
Plain XSLT won't help here.
I need to extract the string and pass it as a param, say, to a reader.

Alexander.
//////////////


>
> Alexander Berezhnoy wrote:
> > Dear friends,
> > I've been looking for this feature for a week already, nobody and
nowhere
> > can't give me a definite answer.
> >
> > I want to extract data with XPath from an XML file whoes name depends on
> > request parameters.
> > The XMLFileModule is statically configured, so the file name is fixed.
> >
>
> Why not plain xslt ?
>
> <map:generate type="file" src="{request-param:myfilename}.xml"/>
> <map:transorm src="{request-param:myfilename}.xslt"/>
> <map:serialize type="xml"/>
>
> Why can't you just create the pipeline as such and aggregate it in
> another where you need the data?
>
>
> Or did i misunderstand your question?
>
>
> Jorg
>
>
> ---------------------------------------------------------------------
> 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


Re: XMLFileModule for a dynamic file.

Posted by Jorg Heymans <jh...@domek.be>.
Alexander Berezhnoy wrote:
> Dear friends,
> I've been looking for this feature for a week already, nobody and nowhere
> can't give me a definite answer.
> 
> I want to extract data with XPath from an XML file whoes name depends on
> request parameters.
> The XMLFileModule is statically configured, so the file name is fixed.
> 

Why not plain xslt ?

<map:generate type="file" src="{request-param:myfilename}.xml"/>
<map:transorm src="{request-param:myfilename}.xslt"/>
<map:serialize type="xml"/>

Why can't you just create the pipeline as such and aggregate it in
another where you need the data?


Or did i misunderstand your question?


Jorg


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


Re: XMLFileModule for a dynamic file.

Posted by Mark Lundquist <ml...@comcast.net>.
On 2005-06-01 06:11:24 -0700, "Alexander Berezhnoy" 
<al...@splc.ru> (on users@cocoon.apache.org) said:

> Dear friends,
> I've been looking for this feature for a week already, nobody and nowhere
> can't give me a definite answer.
> 
> I want to extract data with XPath from an XML file whoes name depends on
> request parameters.
> The XMLFileModule is statically configured, so the file name is fixed.
> 
> Please, is it possible without writing my own module?

I ran across this thread today, because I need exactly this very same 
thing! :-)  Alexander, I saw another post of yours around the same 
time, maybe on the dev group or somewhere... I too was faked out a 
little bit by the mention of "dynamic" configuration" in the comments 
for XMLFileModule.  It looks like that stuff (the modConf parameter to 
getAttribute() and friends) is there for use by other Cocoon 
components... see LinkRewriterTransformer for an example.  If you think 
about it, for what you wanted (and what I want :-), the only way to 
specify the source name would have to be in the attribute name syntax 
for the module.  If you don't see it there, then it ain't there and 
this module doesn't do what we want :-/.

So, what I'm after would be an XPathModule, invoked in the sitemap like this:

	{xpath:source-uri#xpath-expression}

e.g. (in the particular appl'n I have for this just now :-):

	<map:relocate-to uri="{xpath:{1}#/relocate-to/@uri}" />

It looks like a reasonable strategy would be to factor most of 
XMLFileModule into a new class AbstractXMLFileModule, and then extend 
this to implement XPathModule.  Comments?

—ml—