Can you elaborate your use case by attaching small xml snippets?  From
what I understand you have some Xml snippet containing an include tag.
Robby my pipeline and XSLT are like:
(Please correct if I 'm wrong)

_My sitemap/pipeline:_

<map:match pattern="root/sub/mypattern.html">
 <map:generate src="somefile.xml"/>
 <map:transform src="myxslt.xsl">
 <map:transform type="include"> 
        <map:parameter name="recursive" value="false"/>
 </map:transform>
<map:serialize type="xml"/> </map:match>


_My XSLT (myxslt.xsl):
_
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns="http://www.w3.org/1999/xhtml";
 xmlns:xhtml="http://www.w3.org/1999/xhtml";
 xmlns:i="http://apache.org/cocoon/include/1.0";

        <xsl:template match="/">
                Some test data
                <i:include src="cocoon://root/sub/mypattern.html"/>             
                
        </xsl:template>
</xsl:stylesheet>

_The output I want is:_

###############
Some test data
Some test data
###############


String "Some test data" for two times. One is from XSLT (first call) and another one is from first include. I agree that I can use different pipeline but I need to use it with:

<map:parameter name="recursive" value="false"/>

Please suggest.

TIA



Robby Pelssers wrote:
By the way.. I think the design of your pipelines is bad after giving it
some more thought.

If you don't want recursive inclusion... you might consider configuring
a new pipeline which does not contain the <i:include> tag at all... you
could filter them out of the result by adding a filter.xslt instead of
rewriting them to another namespace.

And if you did want recursive inclusion... then you should add the
include transformer as last step in the 2nd pipeline.

<map:match pattern="root/sub/mypattern.html">
  <map:generate src="somefile.xml"/>
  <map:transform type="include"/>   --> by adding the include on
sub-level you prevent recursive inclusion
<map:serialize type="xml"/> </map:match>

Cheers,
Robby



-----Original Message-----
From: Robby Pelssers [mailto:[email protected]] Sent: Tuesday, December 08, 2009 2:15 PM
To: [email protected]
Subject: RE: Problem with <i:include>

Can you elaborate your use case by attaching small xml snippets?  From
what I understand you have some Xml snippet containing an include tag.


<?xml version="1.0" encoding="UTF-8"?>
<main>
  <i:include src="cocoon://root/sub/mypattern.html"
xmlns:i="http://apache.org/cocoon/include/1.0"/> </main>


And the result of calling pattern "root/sub/mypattern.html" results in
another snippet containing an include tag.

<?xml version="1.0" encoding="UTF-8"?>
<mypattern>
  <i:include src="cocoon://someOtherPipeline"
xmlns:i="http://apache.org/cocoon/include/1.0"/> </mypattern>


So what you want is only first level inclusion so the result becomes:

<?xml version="1.0" encoding="UTF-8"?>
<main>
  <mypattern>
    <i:include src="cocoon://someOtherPipeline"
xmlns:i="http://apache.org/cocoon/include/1.0"/>    --> this is the
problem since it's recursive
  </mypattern>
</main>


Now... if you were to add a extra transformation step to the pipeline
"root/sub/mypattern.html" which transforms the <i:include> into a
different namespace...you will be sure that the includeTransformer will
not run into recursion.

So the result would become for instance
<?xml version="1.0" encoding="UTF-8"?>
<main>
  <mypattern>
    <ignoreInclude:include src="cocoon://someOtherPipeline"
xmlns:ignoreInclude="http://apache.org/cocoon/ignoreInclude/1.0"/>
  </mypattern>
</main>

Does that approach a solution to your problem?

Robby

-----Original Message-----
From: Anish [mailto:[email protected]] Sent: Tuesday, December 08, 2009 1:53 PM
To: [email protected]
Subject: Re: Problem with <i:include>

Robby Pelssers wrote:
I actually do the same but not 1 one go... I split my transformations
in
multiple sequential includes and that gives me no problem:

      <map:match pattern="datasheet_mockup">
        <map:generate src="data/datasheet_mockup.xml" label="step-1"/>

        <map:transform type="cinclude" label="step-2"/> <!-- Include
<PackageID> -->
        <map:transform src="xslt/includePackageAndProductXml.xslt"
label="step-3"/>
        <map:transform type="cinclude" label="step-4"/>  <!-- Include
actual Package and Product xml -->
        <map:transform src="xslt/addGroupId.xslt" type="saxon"
label="step-5"/> <map:transform src="xslt/createMapAndTopics.xslt" type="saxon" label="step-6"/> <map:transform type="cinclude" label="step-7"/> <!-- include
BoxDimensions -->
        <map:transform src="xslt/replaceBoxDimensions.xslt"
type="saxon"
label="step-8"/>
        <map:transform src="xslt/cleanup.xslt" type="saxon"/>

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

Maybe this won't work for your usecase but it's worthwile considering.

Robby
-----Original Message-----
From: Anish [mailto:[email protected]] Sent: Tuesday, December 08, 2009 1:10 PM
To: [email protected]
Subject: Problem with <i:include>

Hi All

I'm trying to include content from a pipeline into an XSLT using:

<i:include src="cocoon://root/sub/mypattern.html"
xmlns:i="http://apache.org/cocoon/include/1.0";>


while executing it gives:

java.lang.StackOverflowError
        java.util.HashMap.get(HashMap.java:343)
        

org.apache.cocoon.environment.AbstractEnvironment.getAttribute(AbstractE
nvironment.java:444)
        

org.apache.cocoon.environment.wrapper.EnvironmentWrapper.getAttribute(En
vironmentWrapper.java:415)
        

org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade.getAttrib
ute(MutableEnvironmentFacade.java:227)

There is a recursive call in the XSLT which again calls same pipeline
to
include, to avoid that I have set (in the pipeline):

<map:parameter name="recursive" value="false"/>


Still it's causing the stack to overflow. I'm using Cocoon 2.1.10 on Tomcat 5.5.17.
Please suggest.

Thanks Robby,

Actually I was using "include" (org.apache.cocoon.transformation.IncludeTransformer) transformer. I'm not very much clear about the difference between "include" and "cinclude" (org.apache.cocoon.transformation.CIncludeTransformer).

Also I don't need recursive call. At the time of include I just want to include it once (the first level only).


Please suggest.



--
Anish Sneh
Software Engineer
Techblue Softwares Pvt. Ltd.
www.technologyblueprint.co.uk



Reply via email to