You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kasper Nielsen <ne...@kav.dk> on 2002/11/05 14:27:17 UTC

simpel cocoon question

Just started using Cocoon and I have a rather simple question:

Lets say i have a document with all my data (projects.xml)
<projects>
    <project id="A1">
        <name> RailwayTrack DF</name>
        <responsible> kni </responsible>
        <economy_actual>123</economy_actual>
        <economy_estimate>456</economy_estimate>
        <schedule_estimate>789</economy_estimate>
    </project>
    <project id="B4">
        <name> Digital Transmission </name>
        <responsible> pjc </responsible>
        <economy_actual>987</economy_actual>
        <economy_estimate>654</economy_estimate>
        <schedule_estimate>321</economy_estimate>
    </project>
    ............
</projects>

And i also have a definition of some views of the data (views.xml)

<views>
    <view name="estimate">
        <columns>
            <measure name="schedule_estimate"/>
            <measure name="economy_estimate"/>
        </columns>
    </view>
    <view name="overview">
        <columns>
            <measure name="name"/>
            <measure name="responsible"/>
        </columns>
    </view>
</views>

Now I want to given the name of the view, lets say "estimate" to combine it
into another xml document, that is extract only the data mentioned in the
view, in this case it would be the "schedule_estimate" column and the
"economy_estimate" column
The resulting document should look something like this
<table>
    <columndefs>
        <columndef>
            <column-name>schedule_estimate</column-name>
        </columndef>
        <columndef>
            <column-name>economy_estimate</column-name>
        </columndef>
    </columndefs>
    <tabledata>
        <row>
            <entry>456</entry>
            <entry>789</entry>
        </row>
        <row>
            <entry>654</entry>
            <entry>321</entry>
        </row>
    </tabledata>
</table>

Can I "merge" 2 documents in that way with xslt?
Or do I need a custom transformer?

regards
  Kasper Nielsen


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simpel cocoon question

Posted by Marcus Crafter <cr...@fztig938.bank.dresdner.net>.
Hi Kasper,

	You wouldn't need to write a custom transformer for this. One
	solution would be to use aggregation to aggregate both files
	together. Then using xsl you can extract the necessary data
	for output.
	
	Hope that helps.
	
	Cheers,
	
	Marcus
	
On Tue, Nov 05, 2002 at 02:27:17PM +0100, Kasper Nielsen wrote:
> Just started using Cocoon and I have a rather simple question:
> 
> Lets say i have a document with all my data (projects.xml)
> <projects>
>     <project id="A1">
>         <name> RailwayTrack DF</name>
>         <responsible> kni </responsible>
>         <economy_actual>123</economy_actual>
>         <economy_estimate>456</economy_estimate>
>         <schedule_estimate>789</economy_estimate>
>     </project>
>     <project id="B4">
>         <name> Digital Transmission </name>
>         <responsible> pjc </responsible>
>         <economy_actual>987</economy_actual>
>         <economy_estimate>654</economy_estimate>
>         <schedule_estimate>321</economy_estimate>
>     </project>
>     ............
> </projects>
> 
> And i also have a definition of some views of the data (views.xml)
> 
> <views>
>     <view name="estimate">
>         <columns>
>             <measure name="schedule_estimate"/>
>             <measure name="economy_estimate"/>
>         </columns>
>     </view>
>     <view name="overview">
>         <columns>
>             <measure name="name"/>
>             <measure name="responsible"/>
>         </columns>
>     </view>
> </views>
> 
> Now I want to given the name of the view, lets say "estimate" to combine it
> into another xml document, that is extract only the data mentioned in the
> view, in this case it would be the "schedule_estimate" column and the
> "economy_estimate" column
> The resulting document should look something like this
> <table>
>     <columndefs>
>         <columndef>
>             <column-name>schedule_estimate</column-name>
>         </columndef>
>         <columndef>
>             <column-name>economy_estimate</column-name>
>         </columndef>
>     </columndefs>
>     <tabledata>
>         <row>
>             <entry>456</entry>
>             <entry>789</entry>
>         </row>
>         <row>
>             <entry>654</entry>
>             <entry>321</entry>
>         </row>
>     </tabledata>
> </table>
> 
> Can I "merge" 2 documents in that way with xslt?
> Or do I need a custom transformer?
> 
> regards
>   Kasper Nielsen
> 
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
> 

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Insert XML String in XSP

Posted by Ludovic de Beaurepaire <lu...@axonie.com>.
Hi All,

In an XSP I want an XML String data to be parsed into the event pipeline,
but if I use <xsp:expr> element, my XML data is evaluated as a String
(<hello/> becomes &lt;hello/&gt;).

I looked at XSPObjectHelper apidoc, and two methods allowed the parsing of
xml datas :
- xspExpr(org.xml.sax.ContentHandler contentHandler, XMLizable v)
-xspExpr(org.xml.sax.ContentHandler contentHandler, org.w3c.dom.Node v)

But I did not find any XMLizable extending class allowing the usage of a
String, and I think that using DOM is not optimized in the cocoon
architecture if my string is too long.

A solution to use XMLizable (or an example for org.w3c.dom.Node) ?

Thanks,

Ludovic


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simpel cocoon question

Posted by SAXESS - Hussayn Dabbous <da...@saxess.com>.
Hello, Joerg;

thank you very much for the info.
The other solution is indeed much nicer, and much easier to
understand than mine ;-)

regards, hussayn

Joerg Heinicke wrote:
> Hello Hussayn,
> 
> the question was also on the XSL list yesterday and there is a simpler 
> solution:
> 
> http://www.biglist.com/lists/xsl-list/archives/200211/msg00188.html
> 

-- 
Dr. Hussayn Dabbous
SAXESS Software Design GmbH
Neuenhöfer Allee 125
50935 Köln
Telefon: +49-221-56011-0
Fax:     +49-221-56011-20
E-Mail:  dabbous@saxess.com


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simpel cocoon question

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Hussayn,

the question was also on the XSL list yesterday and there is a simpler solution:

http://www.biglist.com/lists/xsl-list/archives/200211/msg00188.html

Furthermore version="1.1" is only supported in pre-implementations of Saxon. 
XSL 1.1 died in Working Draft status.

Regards,

Joerg


SAXESS - Hussayn Dabbous wrote:
> Hy;
> 
> The stylesheet below will do it. The trick is recursively
> calling the template "project-measure".
> I would be interested, if there is a more elegant/efficient
> way, doing this in xslt or inside of cocoon ...
> 
> regards, hussayn
> 
> 
> <?xml version="1.0"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version='1.1'>
> 
> <xsl:output indent="yes"/>
> 
> <xsl:variable name="measure-count" 
> select="count(/all/view/columns/measure)"/>
> 
> <xsl:template match="projects">
>   <projects>
>     <xsl:apply-templates/>
>   </projects>
> </xsl:template>
> 
> <xsl:template match="project">
>   <project>
>     <xsl:call-template name="project-measure"/>
>   </project>
> </xsl:template>
> 
> <xsl:template name="project-measure">
>   <xsl:param name="position">1</xsl:param>
>   <xsl:variable name="name" 
> select="../../view/columns/measure[position()=$position]/@name"/>
>   <xsl:apply-templates select="measure[@name=$name]"/>
>   <xsl:if test="$position &lt; $measure-count">
>     <xsl:call-template name="project-measure">
>       <xsl:with-param name="position" select="$position + 1"/>
>     </xsl:call-template>
>   </xsl:if>
> </xsl:template>
> 
> <xsl:template match="project/measure">
>  <xsl:copy-of select="."/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> 
> Kasper Nielsen wrote:
> 
>> Thanks for the hints, aggregation is the way to go for sure, but im still
>> facing a problem
>>
>> Basicly what im looking for is how to (fastest possible way) do to a 
>> project
>> (relational algebra) operation on a long list of relations in xsl.
>> Im not sure this should be done in xsl perhaps I need a custom 
>> transformer
>> anyway
>>
>> Let's say I have this document
>>
>> <all>
>>
>>     <view name="economy">
>>         <columns>
>>             <measure name="economy_estimate"/>
>>             <measure name="economy_actual"/>
>>             <measure name="responsible"/>
>>         </columns>
>>     </view>
>>
>>     <projects>
>>         <project>
>>             <measure name="responsible"> kav </measure>
>>             <measure name="economy_actual">991233</measure>
>>             <measure name="economy_estimate">881123</measure>
>>             <measure name="schedule_actual">123</measure>
>>             <measure name="schedule_estimate">823</measure>
>>         </project>
>>         <project>
>>             <measure name="responsible"> pjc </measure>
>>             <measure name="economy_actual">77123123</measure>
>>             <measure name="economy_estimate">44123123</measure>
>>             <measure name="schedule_actual">723</measure>
>>             <measure name="schedule_estimate">923</measure>
>>         </project>
>>         ..... 100's of other projects....
>>     </projects>
>> </all>
>>
>> how do I transform this document into something like this:
>> The order between measures is as defined in the view part, ie (estimate
>> before actual) before responsible
>>
>> <projects>
>>   <project>
>>     <measure name="economy_estimate">881123</measure>
>>     <measure name="economy_actual">991233</measure>
>>     <measure name="responsible"> kav </measure>
>>   </project>
>>   <project>
>>     <measure name="economy_estimate">44123123</measure>
>>     <measure name="economy_actual">77123123</measure>
>>     <measure name="responsible"> pjc </measure>
>>   </project>
>> </projects>
>>
>>
>> regards
>>   Kasper
>>
>>
>> ----- Original Message -----
>> From: "Kasper Nielsen" <ne...@kav.dk>
>> To: <co...@xml.apache.org>
>> Sent: Tuesday, November 05, 2002 2:27 PM
>> Subject: simpel cocoon question
>>
>>
>>
>>> Just started using Cocoon and I have a rather simple question:
>>>
>>> Lets say i have a document with all my data (projects.xml)
>>> <projects>
>>>    <project id="A1">
>>>        <name> RailwayTrack DF</name>
>>>        <responsible> kni </responsible>
>>>        <economy_actual>123</economy_actual>
>>>        <economy_estimate>456</economy_estimate>
>>>        <schedule_estimate>789</economy_estimate>
>>>    </project>
>>>    <project id="B4">
>>>        <name> Digital Transmission </name>
>>>        <responsible> pjc </responsible>
>>>        <economy_actual>987</economy_actual>
>>>        <economy_estimate>654</economy_estimate>
>>>        <schedule_estimate>321</economy_estimate>
>>>    </project>
>>>    ............
>>> </projects>
>>>
>>> And i also have a definition of some views of the data (views.xml)
>>>
>>> <views>
>>>    <view name="estimate">
>>>        <columns>
>>>            <measure name="schedule_estimate"/>
>>>            <measure name="economy_estimate"/>
>>>        </columns>
>>>    </view>
>>>    <view name="overview">
>>>        <columns>
>>>            <measure name="name"/>
>>>            <measure name="responsible"/>
>>>        </columns>
>>>    </view>
>>> </views>
>>>
>>> Now I want to given the name of the view, lets say "estimate" to combine
>>
>>
>> it
>>
>>> into another xml document, that is extract only the data mentioned in 
>>> the
>>> view, in this case it would be the "schedule_estimate" column and the
>>> "economy_estimate" column
>>> The resulting document should look something like this
>>> <table>
>>>    <columndefs>
>>>        <columndef>
>>>            <column-name>schedule_estimate</column-name>
>>>        </columndef>
>>>        <columndef>
>>>            <column-name>economy_estimate</column-name>
>>>        </columndef>
>>>    </columndefs>
>>>    <tabledata>
>>>        <row>
>>>            <entry>456</entry>
>>>            <entry>789</entry>
>>>        </row>
>>>        <row>
>>>            <entry>654</entry>
>>>            <entry>321</entry>
>>>        </row>
>>>    </tabledata>
>>> </table>
>>>
>>> Can I "merge" 2 documents in that way with xslt?
>>> Or do I need a custom transformer?
>>>
>>> regards
>>>  Kasper Nielsen


-- 

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simpel cocoon question

Posted by SAXESS - Hussayn Dabbous <da...@saxess.com>.
Hy;

The stylesheet below will do it. The trick is recursively
calling the template "project-measure".
I would be interested, if there is a more elegant/efficient
way, doing this in xslt or inside of cocoon ...

regards, hussayn


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version='1.1'>

<xsl:output indent="yes"/>

<xsl:variable name="measure-count" 
select="count(/all/view/columns/measure)"/>

<xsl:template match="projects">
   <projects>
     <xsl:apply-templates/>
   </projects>
</xsl:template>

<xsl:template match="project">
   <project>
     <xsl:call-template name="project-measure"/>
   </project>
</xsl:template>

<xsl:template name="project-measure">
   <xsl:param name="position">1</xsl:param>
   <xsl:variable name="name" 
select="../../view/columns/measure[position()=$position]/@name"/>
   <xsl:apply-templates select="measure[@name=$name]"/>
   <xsl:if test="$position &lt; $measure-count">
     <xsl:call-template name="project-measure">
       <xsl:with-param name="position" select="$position + 1"/>
     </xsl:call-template>
   </xsl:if>
</xsl:template>

<xsl:template match="project/measure">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>



Kasper Nielsen wrote:
> Thanks for the hints, aggregation is the way to go for sure, but im still
> facing a problem
> 
> Basicly what im looking for is how to (fastest possible way) do to a project
> (relational algebra) operation on a long list of relations in xsl.
> Im not sure this should be done in xsl perhaps I need a custom transformer
> anyway
> 
> Let's say I have this document
> 
> <all>
> 
>     <view name="economy">
>         <columns>
>             <measure name="economy_estimate"/>
>             <measure name="economy_actual"/>
>             <measure name="responsible"/>
>         </columns>
>     </view>
> 
>     <projects>
>         <project>
>             <measure name="responsible"> kav </measure>
>             <measure name="economy_actual">991233</measure>
>             <measure name="economy_estimate">881123</measure>
>             <measure name="schedule_actual">123</measure>
>             <measure name="schedule_estimate">823</measure>
>         </project>
>         <project>
>             <measure name="responsible"> pjc </measure>
>             <measure name="economy_actual">77123123</measure>
>             <measure name="economy_estimate">44123123</measure>
>             <measure name="schedule_actual">723</measure>
>             <measure name="schedule_estimate">923</measure>
>         </project>
>         ..... 100's of other projects....
>     </projects>
> </all>
> 
> how do I transform this document into something like this:
> The order between measures is as defined in the view part, ie (estimate
> before actual) before responsible
> 
> <projects>
>   <project>
>     <measure name="economy_estimate">881123</measure>
>     <measure name="economy_actual">991233</measure>
>     <measure name="responsible"> kav </measure>
>   </project>
>   <project>
>     <measure name="economy_estimate">44123123</measure>
>     <measure name="economy_actual">77123123</measure>
>     <measure name="responsible"> pjc </measure>
>   </project>
> </projects>
> 
> 
> regards
>   Kasper
> 
> 
> ----- Original Message -----
> From: "Kasper Nielsen" <ne...@kav.dk>
> To: <co...@xml.apache.org>
> Sent: Tuesday, November 05, 2002 2:27 PM
> Subject: simpel cocoon question
> 
> 
> 
>>Just started using Cocoon and I have a rather simple question:
>>
>>Lets say i have a document with all my data (projects.xml)
>><projects>
>>    <project id="A1">
>>        <name> RailwayTrack DF</name>
>>        <responsible> kni </responsible>
>>        <economy_actual>123</economy_actual>
>>        <economy_estimate>456</economy_estimate>
>>        <schedule_estimate>789</economy_estimate>
>>    </project>
>>    <project id="B4">
>>        <name> Digital Transmission </name>
>>        <responsible> pjc </responsible>
>>        <economy_actual>987</economy_actual>
>>        <economy_estimate>654</economy_estimate>
>>        <schedule_estimate>321</economy_estimate>
>>    </project>
>>    ............
>></projects>
>>
>>And i also have a definition of some views of the data (views.xml)
>>
>><views>
>>    <view name="estimate">
>>        <columns>
>>            <measure name="schedule_estimate"/>
>>            <measure name="economy_estimate"/>
>>        </columns>
>>    </view>
>>    <view name="overview">
>>        <columns>
>>            <measure name="name"/>
>>            <measure name="responsible"/>
>>        </columns>
>>    </view>
>></views>
>>
>>Now I want to given the name of the view, lets say "estimate" to combine
> 
> it
> 
>>into another xml document, that is extract only the data mentioned in the
>>view, in this case it would be the "schedule_estimate" column and the
>>"economy_estimate" column
>>The resulting document should look something like this
>><table>
>>    <columndefs>
>>        <columndef>
>>            <column-name>schedule_estimate</column-name>
>>        </columndef>
>>        <columndef>
>>            <column-name>economy_estimate</column-name>
>>        </columndef>
>>    </columndefs>
>>    <tabledata>
>>        <row>
>>            <entry>456</entry>
>>            <entry>789</entry>
>>        </row>
>>        <row>
>>            <entry>654</entry>
>>            <entry>321</entry>
>>        </row>
>>    </tabledata>
>></table>
>>
>>Can I "merge" 2 documents in that way with xslt?
>>Or do I need a custom transformer?
>>
>>regards
>>  Kasper Nielsen
>>
>>
>>---------------------------------------------------------------------
>>Please check that your question  has not already been answered in the
>>FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>>
>>To unsubscribe, e-mail:     <co...@xml.apache.org>
>>For additional commands, e-mail:   <co...@xml.apache.org>
>>
> 
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
> 

-- 
Dr. Hussayn Dabbous
SAXESS Software Design GmbH
Neuenhöfer Allee 125
50935 Köln
Telefon: +49-221-56011-0
Fax:     +49-221-56011-20
E-Mail:  dabbous@saxess.com


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simpel cocoon question

Posted by Kasper Nielsen <ne...@kav.dk>.
Thanks for the hints, aggregation is the way to go for sure, but im still
facing a problem

Basicly what im looking for is how to (fastest possible way) do to a project
(relational algebra) operation on a long list of relations in xsl.
Im not sure this should be done in xsl perhaps I need a custom transformer
anyway

Let's say I have this document

<all>

    <view name="economy">
        <columns>
            <measure name="economy_estimate"/>
            <measure name="economy_actual"/>
            <measure name="responsible"/>
        </columns>
    </view>

    <projects>
        <project>
            <measure name="responsible"> kav </measure>
            <measure name="economy_actual">991233</measure>
            <measure name="economy_estimate">881123</measure>
            <measure name="schedule_actual">123</measure>
            <measure name="schedule_estimate">823</measure>
        </project>
        <project>
            <measure name="responsible"> pjc </measure>
            <measure name="economy_actual">77123123</measure>
            <measure name="economy_estimate">44123123</measure>
            <measure name="schedule_actual">723</measure>
            <measure name="schedule_estimate">923</measure>
        </project>
        ..... 100's of other projects....
    </projects>
</all>

how do I transform this document into something like this:
The order between measures is as defined in the view part, ie (estimate
before actual) before responsible

<projects>
  <project>
    <measure name="economy_estimate">881123</measure>
    <measure name="economy_actual">991233</measure>
    <measure name="responsible"> kav </measure>
  </project>
  <project>
    <measure name="economy_estimate">44123123</measure>
    <measure name="economy_actual">77123123</measure>
    <measure name="responsible"> pjc </measure>
  </project>
</projects>


regards
  Kasper


----- Original Message -----
From: "Kasper Nielsen" <ne...@kav.dk>
To: <co...@xml.apache.org>
Sent: Tuesday, November 05, 2002 2:27 PM
Subject: simpel cocoon question


> Just started using Cocoon and I have a rather simple question:
>
> Lets say i have a document with all my data (projects.xml)
> <projects>
>     <project id="A1">
>         <name> RailwayTrack DF</name>
>         <responsible> kni </responsible>
>         <economy_actual>123</economy_actual>
>         <economy_estimate>456</economy_estimate>
>         <schedule_estimate>789</economy_estimate>
>     </project>
>     <project id="B4">
>         <name> Digital Transmission </name>
>         <responsible> pjc </responsible>
>         <economy_actual>987</economy_actual>
>         <economy_estimate>654</economy_estimate>
>         <schedule_estimate>321</economy_estimate>
>     </project>
>     ............
> </projects>
>
> And i also have a definition of some views of the data (views.xml)
>
> <views>
>     <view name="estimate">
>         <columns>
>             <measure name="schedule_estimate"/>
>             <measure name="economy_estimate"/>
>         </columns>
>     </view>
>     <view name="overview">
>         <columns>
>             <measure name="name"/>
>             <measure name="responsible"/>
>         </columns>
>     </view>
> </views>
>
> Now I want to given the name of the view, lets say "estimate" to combine
it
> into another xml document, that is extract only the data mentioned in the
> view, in this case it would be the "schedule_estimate" column and the
> "economy_estimate" column
> The resulting document should look something like this
> <table>
>     <columndefs>
>         <columndef>
>             <column-name>schedule_estimate</column-name>
>         </columndef>
>         <columndef>
>             <column-name>economy_estimate</column-name>
>         </columndef>
>     </columndefs>
>     <tabledata>
>         <row>
>             <entry>456</entry>
>             <entry>789</entry>
>         </row>
>         <row>
>             <entry>654</entry>
>             <entry>321</entry>
>         </row>
>     </tabledata>
> </table>
>
> Can I "merge" 2 documents in that way with xslt?
> Or do I need a custom transformer?
>
> regards
>   Kasper Nielsen
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Poor performance of document() in XSL [Was: Re: simpel cocoon question]

Posted by "Ilya A. Kriveshko" <il...@kaon.com>.
J.Pietschmann wrote:

>> document() is good for rapid prototyping, but is a poor choice for final
>> deployment for performance reasons. Use aggregation instead.
>
> The Cocoon developers recommend to use aggregation or xinclude
> because of SoC (XSLT is for transforming, not for aggregating
> content). I'd add the cache issue. The performance problem
> is easily dealt with.

Thanks for the clarification.



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: Poor performance of document() in XSL [Was: Re: simpel cocoon question]

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Ilya A. Kriveshko wrote:
> SAXESS - Hussayn Dabbous wrote:
>> But you also could do it directly within the xslt context:
>> You can use the document() function in your XSLT-file.

There are drawbacks. One of them is that Cocoon currently
(2.0.3) does not check XML sources referenced via document()
for changes. You'll get the cached result even if document()
sources change until you invalidate the main input source
for the transformation step (or the style sheet).

Q: It was said 2.1 will fix this. Is this still true?

> In the past I have encountered a nasty performance problem with document().
This is a Xalan peculiarity. It acesses the source every time
a document() call is encountered, even though the XSLT spec
requires that always the same XML tree is returned (and Xalan
adheres to it). There is a bug pending (#2425).

Saxon does not have this problem. I don't know about XSLTC.
Has someone already tried?

> I say,
> document() is good for rapid prototyping, but is a poor choice for final
> deployment for performance reasons. Use aggregation instead.

The Cocoon developers recommend to use aggregation or xinclude
because of SoC (XSLT is for transforming, not for aggregating
content). I'd add the cache issue. The performance problem
is easily dealt with.

J.Pietschmann


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: Poor performance of document() in XSL [Was: Re: simpel cocoon question]

Posted by Leigh Dodds <ld...@ingenta.com>.
A naive implementation of the document() function is likely
to do this. However happily, by implementing the
javax.xml.transform.URIResolver interface [1], and setting
this on the Tranformer using setURIResolver [2] you can easily
plug in a simple cache (e.g. hash of URL versus retrieved content)
that avoid multiple network overheads.

I have a sample implementation and simple test harness
if anyone wants it.

Cheers,

L.


[1]. http://java.sun.com/j2se/1.4/docs/api/javax/xml/transform/URIResolver.html
[2].
http://java.sun.com/j2se/1.4/docs/api/javax/xml/transform/Transformer.html#setURIResolver(javax.xml.
transform.URIResolver)

> -----Original Message-----
> From: Ilya A. Kriveshko [mailto:ilya@kaon.com]
> Sent: 05 November 2002 14:33
> To: cocoon-users@xml.apache.org
> Subject: Poor performance of document() in XSL [Was: Re: simpel cocoon
> question]
>
>
> SAXESS - Hussayn Dabbous wrote:
>
> > <snip/>
> > But you also could do it directly within the xslt context:
> > You can use the document() function in your XSLT-file.
> > This function allows you to refer to data contained within
> > another XML-file. This is completely decoupled from cocoon
> > though. It's more about how to work with XSLT:
> > <snip/>
>
>
> In the past I have encountered a nasty performance problem with document().
> For example, when you declare an xsl variable that gets its value from a
> document(),
> and then use its value several times throughout the stylesheet, the URI
> of the document
> gets hist as many times as there are references to that variable. I.e.
> the xsl variable
> does not store the XML fragment it was given at the variable definition
> time, but
> merely stores the XPath string and then resolves it every time it's
> referenced.
> This may or may not be true for XPath expressions that do not contain
> document()
> as well. Does anyone know for sure?
>
> Example:
>
> <xsl:variable name="test-me"
> select="document('cocoon:/gimme-sumthn')/sumthn/in/@there"/>
>
> <xsl:template match="/">
>   <this-is-just-a-test>
>     <xsl:value-of select="$test-me"/>
>     <xsl:value-of select="$test-me"/>
>     <xsl:value-of select="$test-me"/>
>   </this-is-just-a-test>
> </xsl:template>
>
> When using Xalan, this example will cause the Cocoon pipeline that
> is responsible for "gimme-sumthn" to be hit three times. I say,
> document() is good for rapid prototyping, but is a poor choice for final
> deployment for performance reasons. Use aggregation instead.
>
> +2c
> --
> Ilya
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Poor performance of document() in XSL [Was: Re: simpel cocoon question]

Posted by "Ilya A. Kriveshko" <il...@kaon.com>.
SAXESS - Hussayn Dabbous wrote:

> <snip/>
> But you also could do it directly within the xslt context:
> You can use the document() function in your XSLT-file.
> This function allows you to refer to data contained within
> another XML-file. This is completely decoupled from cocoon
> though. It's more about how to work with XSLT:
> <snip/>


In the past I have encountered a nasty performance problem with document().
For example, when you declare an xsl variable that gets its value from a 
document(),
and then use its value several times throughout the stylesheet, the URI 
of the document
gets hist as many times as there are references to that variable. I.e. 
the xsl variable
does not store the XML fragment it was given at the variable definition 
time, but
merely stores the XPath string and then resolves it every time it's 
referenced.
This may or may not be true for XPath expressions that do not contain 
document()
as well. Does anyone know for sure?

Example:

<xsl:variable name="test-me" 
select="document('cocoon:/gimme-sumthn')/sumthn/in/@there"/>

<xsl:template match="/">
  <this-is-just-a-test>
    <xsl:value-of select="$test-me"/>
    <xsl:value-of select="$test-me"/>
    <xsl:value-of select="$test-me"/>
  </this-is-just-a-test>
</xsl:template>

When using Xalan, this example will cause the Cocoon pipeline that
is responsible for "gimme-sumthn" to be hit three times. I say,
document() is good for rapid prototyping, but is a poor choice for final
deployment for performance reasons. Use aggregation instead.

+2c
--
Ilya





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simpel cocoon question (typo-correction)

Posted by SAXESS - Hussayn Dabbous <da...@saxess.com>.
Hy again;
Sorry, there was a typo in my example. Of course
it must be:

1.) From within the cocoon sitemap you would
create something like this within a pipeline:

<map:match pattern="projects.xml">
   <map:generate  src="/projects.xml"/>
   <map:transform type="xslt" src="mytransformer.xsl">
     <map:parameter name="viewfile" value="views.xml"/>
   </map:transform>
   <map:serialize/>
</map:match>

regards, hussayn

SAXESS - Hussayn Dabbous wrote:
> Hy;
> 
> I'm also new to cocoon, but i think, your
> problem can be solved directly using the
> sitemap capabilities by merging the two xml files with
> aggregation then applying a stylesheet on the merged
> data...
> 
> But you also could do it directly within the xslt context:
> You can use the document() function in your XSLT-file.
> This function allows you to refer to data contained within
> another XML-file. This is completely decoupled from cocoon
> though. It's more about how to work with XSLT:
> 
> 1.) From within the cocoon sitemap you would
> create something like this within a pipeline:
> 
> <map:match pattern="projects.xml">
>   <map:generate  src="/projects.xml"/>
>   <map:transform type="xslt" src="mytransformer.xsl">
>     <map:parameter name="viewfile" value="views.xsl"/>
>   </map:transform>
>   <map:serialize/>
> </map:match>
> 
> 
> 2.) In the stylesheet you would then include a global parameter
> outside of any template:
> 
> <xsl:param name="viewfile">standardviews.xml</xsl:param>
> 
> Note: the value "standardviews.xml" is taken, if you don't
> apply the parameter as stated in 1.)
> 
> 
> 3.) Then finally you would refer to an element in the viewfile
> via select attribute. e.g. if you would want to iterate through
> your view elements:
> 
> <xsl:for-each select="document($viewfile)/views/view">
> . . .
> </xsl:for-each>
> 
> you can use this wherever you can apply a select attribute...
> 
> 
> Hope, that helps getting further. Maybe there are better
> solutions. Maybe the aggregation within a pipeline makes it
> even simpler for you.
> 
> regards, hussayn
-- 
Dr. Hussayn Dabbous
SAXESS Software Design GmbH
Neuenhöfer Allee 125
50935 Köln
Telefon: +49-221-56011-0
Fax:     +49-221-56011-20
E-Mail:  dabbous@saxess.com


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: simpel cocoon question

Posted by SAXESS - Hussayn Dabbous <da...@saxess.com>.
Hy;

I'm also new to cocoon, but i think, your
problem can be solved directly using the
sitemap capabilities by merging the two xml files with
aggregation then applying a stylesheet on the merged
data...

But you also could do it directly within the xslt context:
You can use the document() function in your XSLT-file.
This function allows you to refer to data contained within
another XML-file. This is completely decoupled from cocoon
though. It's more about how to work with XSLT:

1.) From within the cocoon sitemap you would
create something like this within a pipeline:

<map:match pattern="projects.xml">
   <map:generate  src="/projects.xml"/>
   <map:transform type="xslt" src="mytransformer.xsl">
     <map:parameter name="viewfile" value="views.xsl"/>
   </map:transform>
   <map:serialize/>
</map:match>


2.) In the stylesheet you would then include a global parameter
outside of any template:

<xsl:param name="viewfile">standardviews.xml</xsl:param>

Note: the value "standardviews.xml" is taken, if you don't
apply the parameter as stated in 1.)


3.) Then finally you would refer to an element in the viewfile
via select attribute. e.g. if you would want to iterate through
your view elements:

<xsl:for-each select="document($viewfile)/views/view">
. . .
</xsl:for-each>

you can use this wherever you can apply a select attribute...


Hope, that helps getting further. Maybe there are better
solutions. Maybe the aggregation within a pipeline makes it
even simpler for you.

regards, hussayn

Kasper Nielsen wrote:
> Just started using Cocoon and I have a rather simple question:
> 
> Lets say i have a document with all my data (projects.xml)
> <projects>
>     <project id="A1">
>         <name> RailwayTrack DF</name>
>         <responsible> kni </responsible>
>         <economy_actual>123</economy_actual>
>         <economy_estimate>456</economy_estimate>
>         <schedule_estimate>789</economy_estimate>
>     </project>
>     <project id="B4">
>         <name> Digital Transmission </name>
>         <responsible> pjc </responsible>
>         <economy_actual>987</economy_actual>
>         <economy_estimate>654</economy_estimate>
>         <schedule_estimate>321</economy_estimate>
>     </project>
>     ............
> </projects>
> 
> And i also have a definition of some views of the data (views.xml)
> 
> <views>
>     <view name="estimate">
>         <columns>
>             <measure name="schedule_estimate"/>
>             <measure name="economy_estimate"/>
>         </columns>
>     </view>
>     <view name="overview">
>         <columns>
>             <measure name="name"/>
>             <measure name="responsible"/>
>         </columns>
>     </view>
> </views>
> 
> Now I want to given the name of the view, lets say "estimate" to combine it
> into another xml document, that is extract only the data mentioned in the
> view, in this case it would be the "schedule_estimate" column and the
> "economy_estimate" column
> The resulting document should look something like this
> <table>
>     <columndefs>
>         <columndef>
>             <column-name>schedule_estimate</column-name>
>         </columndef>
>         <columndef>
>             <column-name>economy_estimate</column-name>
>         </columndef>
>     </columndefs>
>     <tabledata>
>         <row>
>             <entry>456</entry>
>             <entry>789</entry>
>         </row>
>         <row>
>             <entry>654</entry>
>             <entry>321</entry>
>         </row>
>     </tabledata>
> </table>
> 
> Can I "merge" 2 documents in that way with xslt?
> Or do I need a custom transformer?
> 
> regards
>   Kasper Nielsen
> 
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
> 

-- 
Dr. Hussayn Dabbous
SAXESS Software Design GmbH
Neuenhöfer Allee 125
50935 Köln
Telefon: +49-221-56011-0
Fax:     +49-221-56011-20
E-Mail:  dabbous@saxess.com


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>