You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Dirk Reiss <d....@tu-bs.de> on 2002/03/13 13:17:38 UTC

Call of dynamically created tags in logicsheets

Hello,

we have the follogwing logicsheet where we dynamically create a tag with the content of the return value of a java method. The creation of the tag is working very well so that I did not included the Java-code in this example. The output in the browser is currently a file having a tag

<ownnamespace:toInsert>Content</ownnamespace:toInsert>

We thought that an <apply-templates/> would cause Cocoon to apply the template <ownnamespace:toInsert> being part of the logicsheet but it does not work for us. Is this not possible within a logicsheet to create dynamically tags because it was working during the later transformation process. If it is possible, please let us know what we have to change. If you need further information, please let us know so that we can provide them.

Thanks,
Dirk

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsp="http://apache.org/xsp"
                xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
                xmlns:xinclude="http://www.w3.org/2001/XInclude"
                xmlns:util="http://apache.org/xsp/util/2.0"
                >


<xsl:template match="ownnamespace:header">
    <xsp:logic>
 
  <!-- some Java code -->
  </xsp:logic>  

  <xsl:apply-templates/>
</xsl:template>


<xsl:template match="ownnamespace:link">
        <ownnamespace:toInsert>
                <xsp:expr>getURI("<xsl:value-of select="@identifier"/>")</xsp:expr>
        </ownnamespace:toInsert>
        <xsl:apply-templates/>
</xsl:template>

        
<xsl:template match="ownnamespace:toInsert">
        <xsl:apply-templates select="document(.)" /> 
</xsl:template>  

<xsl:template match="@*|node()" priority="-1">
        <xsl:copy>
              <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
</xsl:template>

</xsl:stylesheet>


--------------

The xsp-page which is used to call the logicsheet looks as follows

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsp:page
          language="java"
          xmlns:xsp="http://apache.org/xsp"
          xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
        xmlns:util="http://www.apache.org/1999/XSP/Util" 
        xmlns:xinclude="http://www.w3.org/2001/XInclude"
>
        <ownnamespace:header/>

  <page>
        <ownnamespace:link identifier="IDENTIFIER"/>          
  </page>
</xsp:page>


RE: Call of dynamically created tags in logicsheets

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Dirk Reiss [mailto:d.reiss@tu-bs.de]
> 
> Hello again,
> 
> thank you very much, this works fine, but the next problem is, that
several
> files are not processed
> recursively, which means: one file links to another which (for itself)
> contains/links to another using the same tags
> as the first one...
> this means, that we would have to include these files "on-the-fly" and
start
> over parsing the included  content.
> 
> is this possible? as far as we understand, the serverpages-generator
would
> have to be called again after the
> cinclude-transformer... is this right?

To resolve all this recursively, try including not the xml *file* (which
could reference another file), but already processed xml *resource*
(file with all of the references resolved). To do this, use
cinclude:include to include not the files, but cocoon: protocol
resource.

It could look like this:

--------- a.xml or xsp or whatever ----------------
<a>
  <cinclude:include src="cocoon:/processed/b.xml"
</a>

--------- b.xml or xsp or whatever ----------------
<b>
  <cinclude:include src="cocoon:/processed/c.xml"
</b>

--------- c.xml or xsp or whatever ----------------
<c>
  End
</c>


In the sitemap:

<map:match pattern="processed/*.xsp"
<map:generate type="serverpages" src="{1}.xsp"/>
<map:transform type="cinclude"/>
</map:match>
<map:match pattern="processed/*.xml"
<map:generate type="file" src="{1}.xml"/>
<map:transform type="cinclude"/>
</map:match>

PS Adopt/change as needed, this just to show the way

Vadim 

> btw: we are using logicsheets and cocoon2.0
> 
> thanks for your quick answer
> best regards,
> 
> dirk
> 
> ----- Original Message -----
> From: "Vadim Gritsenko" <va...@verizon.net>
> To: <co...@xml.apache.org>
> Sent: Thursday, March 14, 2002 4:18 PM
> Subject: RE: Call of dynamically created tags in logicsheets
> 
> 
> Dirk & Torsten:
> 
> What I understood: You want to insert content of document using XSLT
> document() function. Name of the document is generated dynamically by
> XSP.
> 
> If this is right, what you have to do:
> 
> ---------- sitemap -------------
> <!-- apply 'ownnamespace' logicsheet to the x.xml,
>      compile and execute server page -->
> <map:generate type="serverpages" src="x.xml"/>
> <!-- do include -->
> <map:transform type="cinclude"/>
> 
> ---------- logicsheet -------------
> <xsl:template match="ownnamespace:link">
>   <cinclude:include>
>     <xsp:attribute name="src"><xsp:expr>getURI("<xsl:value-of
> select="@identifier"/>")</xsp:expr></xsp:attribute>
>   </cinclude:include>
>   <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="ownnamespace:toInsert">
>   <cinclude:include src="."/>
> </xsl:template>
> 
> 
> 
> cinclude namespace should be declared as:
>   xmlns:cinclude="http://apache.org/cocoon/include/1.0"
> 
> Take a look at aggregate.xsp and logicsheet.xsp, it might help.
> 
> Vadim
> 
> -----Original Message-----
> From: Dirk Reiss [mailto:d.reiss@tu-bs.de]
> Sent: Wednesday, March 13, 2002 7:18 AM
> To: cocoon-users@xml.apache.org
> Subject: Call of dynamically created tags in logicsheets
> 
> Hello,
> 
> we have the follogwing logicsheet where we dynamically create a tag
with
> the content of the return value of a java method. The creation of the
> tag is working very well so that I did not included the Java-code in
> this example. The output in the browser is currently a file having a
tag
> 
> <ownnamespace:toInsert>Content</ownnamespace:toInsert>
> 
> We thought that an <apply-templates/> would cause Cocoon to apply the
> template <ownnamespace:toInsert> being part of the logicsheet but it
> does not work for us. Is this not possible within a logicsheet to
create
> dynamically tags because it was working during the later
transformation
> process. If it is possible, please let us know what we have to change.
> If you need further information, please let us know so that we can
> provide them.
> 
> Thanks,
> Dirk
> 
> <?xml version="1.0"?>
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
> xmlns:xinclude="http://www.w3.org/2001/XInclude"
> xmlns:util="http://apache.org/xsp/util/2.0"
> >
> 
> 
> <xsl:template match="ownnamespace:header">
> <xsp:logic>
> 
> <!-- some Java code -->
> </xsp:logic>
> 
> <xsl:apply-templates/>
> </xsl:template>
> 
> 
> <xsl:template match="ownnamespace:link">
> <ownnamespace:toInsert>
> <xsp:expr>getURI("<xsl:value-of
> select="@identifier"/>")</xsp:expr>
> </ownnamespace:toInsert>
> <xsl:apply-templates/>
> </xsl:template>
> 
> 
> <xsl:template match="ownnamespace:toInsert">
> <xsl:apply-templates select="document(.)" />
> </xsl:template>
> 
> <xsl:template match="@*|node()" priority="-1">
> <xsl:copy>
> <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
> 
> 
> --------------
> 
> The xsp-page which is used to call the logicsheet looks as follows
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> 
> <xsp:page
> language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
> xmlns:util="http://www.apache.org/1999/XSP/Util"
> xmlns:xinclude="http://www.w3.org/2001/XInclude"
> >
> <ownnamespace:header/>
> 
> <page>
> <ownnamespace:link identifier="IDENTIFIER"/>
> </page>
> </xsp:page>
> 
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.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/faqs.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/faqs.html>

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


Re: Call of dynamically created tags in logicsheets

Posted by Dirk Reiss <d....@tu-bs.de>.
Hello again,

thank you very much, this works fine, but the next problem is, that several
files are not processed
recursively, which means: one file links to another which (for itself)
contains/links to another using the same tags
as the first one...
this means, that we would have to include these files "on-the-fly" and start
over parsing the included  content.

is this possible? as far as we understand, the serverpages-generator would
have to be called again after the
cinclude-transformer... is this right?

btw: we are using logicsheets and cocoon2.0

thanks for your quick answer
best regards,

dirk

----- Original Message -----
From: "Vadim Gritsenko" <va...@verizon.net>
To: <co...@xml.apache.org>
Sent: Thursday, March 14, 2002 4:18 PM
Subject: RE: Call of dynamically created tags in logicsheets


Dirk & Torsten:

What I understood: You want to insert content of document using XSLT
document() function. Name of the document is generated dynamically by
XSP.

If this is right, what you have to do:

---------- sitemap -------------
<!-- apply 'ownnamespace' logicsheet to the x.xml,
     compile and execute server page -->
<map:generate type="serverpages" src="x.xml"/>
<!-- do include -->
<map:transform type="cinclude"/>

---------- logicsheet -------------
<xsl:template match="ownnamespace:link">
  <cinclude:include>
    <xsp:attribute name="src"><xsp:expr>getURI("<xsl:value-of
select="@identifier"/>")</xsp:expr></xsp:attribute>
  </cinclude:include>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="ownnamespace:toInsert">
  <cinclude:include src="."/>
</xsl:template>



cinclude namespace should be declared as:
  xmlns:cinclude="http://apache.org/cocoon/include/1.0"

Take a look at aggregate.xsp and logicsheet.xsp, it might help.

Vadim

-----Original Message-----
From: Dirk Reiss [mailto:d.reiss@tu-bs.de]
Sent: Wednesday, March 13, 2002 7:18 AM
To: cocoon-users@xml.apache.org
Subject: Call of dynamically created tags in logicsheets

Hello,

we have the follogwing logicsheet where we dynamically create a tag with
the content of the return value of a java method. The creation of the
tag is working very well so that I did not included the Java-code in
this example. The output in the browser is currently a file having a tag

<ownnamespace:toInsert>Content</ownnamespace:toInsert>

We thought that an <apply-templates/> would cause Cocoon to apply the
template <ownnamespace:toInsert> being part of the logicsheet but it
does not work for us. Is this not possible within a logicsheet to create
dynamically tags because it was working during the later transformation
process. If it is possible, please let us know what we have to change.
If you need further information, please let us know so that we can
provide them.

Thanks,
Dirk

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsp="http://apache.org/xsp"
xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
xmlns:xinclude="http://www.w3.org/2001/XInclude"
xmlns:util="http://apache.org/xsp/util/2.0"
>


<xsl:template match="ownnamespace:header">
<xsp:logic>

<!-- some Java code -->
</xsp:logic>

<xsl:apply-templates/>
</xsl:template>


<xsl:template match="ownnamespace:link">
<ownnamespace:toInsert>
<xsp:expr>getURI("<xsl:value-of
select="@identifier"/>")</xsp:expr>
</ownnamespace:toInsert>
<xsl:apply-templates/>
</xsl:template>


<xsl:template match="ownnamespace:toInsert">
<xsl:apply-templates select="document(.)" />
</xsl:template>

<xsl:template match="@*|node()" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


--------------

The xsp-page which is used to call the logicsheet looks as follows

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsp:page
language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
xmlns:util="http://www.apache.org/1999/XSP/Util"
xmlns:xinclude="http://www.w3.org/2001/XInclude"
>
<ownnamespace:header/>

<page>
<ownnamespace:link identifier="IDENTIFIER"/>
</page>
</xsp:page>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.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/faqs.html>

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


RE: Call of dynamically created tags in logicsheets

Posted by Vadim Gritsenko <va...@verizon.net>.
Dirk & Torsten:

What I understood: You want to insert content of document using XSLT
document() function. Name of the document is generated dynamically by
XSP.

If this is right, what you have to do:

---------- sitemap -------------
<!-- apply 'ownnamespace' logicsheet to the x.xml,
     compile and execute server page -->
<map:generate type="serverpages" src="x.xml"/>
<!-- do include -->
<map:transform type="cinclude"/>

---------- logicsheet -------------
<xsl:template match="ownnamespace:link">
  <cinclude:include>
    <xsp:attribute name="src"><xsp:expr>getURI("<xsl:value-of
select="@identifier"/>")</xsp:expr></xsp:attribute>
  </cinclude:include>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="ownnamespace:toInsert">
  <cinclude:include src="."/>
</xsl:template>



cinclude namespace should be declared as:
  xmlns:cinclude="http://apache.org/cocoon/include/1.0"

Take a look at aggregate.xsp and logicsheet.xsp, it might help.

Vadim

-----Original Message-----
From: Dirk Reiss [mailto:d.reiss@tu-bs.de] 
Sent: Wednesday, March 13, 2002 7:18 AM
To: cocoon-users@xml.apache.org
Subject: Call of dynamically created tags in logicsheets

Hello,
 
we have the follogwing logicsheet where we dynamically create a tag with
the content of the return value of a java method. The creation of the
tag is working very well so that I did not included the Java-code in
this example. The output in the browser is currently a file having a tag
 
<ownnamespace:toInsert>Content</ownnamespace:toInsert>
 
We thought that an <apply-templates/> would cause Cocoon to apply the
template <ownnamespace:toInsert> being part of the logicsheet but it
does not work for us. Is this not possible within a logicsheet to create
dynamically tags because it was working during the later transformation
process. If it is possible, please let us know what we have to change.
If you need further information, please let us know so that we can
provide them.
 
Thanks,
Dirk
 
<?xml version="1.0"?>
 
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsp="http://apache.org/xsp"
                xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
                xmlns:xinclude="http://www.w3.org/2001/XInclude"
                xmlns:util="http://apache.org/xsp/util/2.0"
                >
 

<xsl:template match="ownnamespace:header">
    <xsp:logic>
 
  <!-- some Java code -->
  </xsp:logic>  
 
  <xsl:apply-templates/>
</xsl:template>
 

<xsl:template match="ownnamespace:link">
        <ownnamespace:toInsert>
                <xsp:expr>getURI("<xsl:value-of
select="@identifier"/>")</xsp:expr>
        </ownnamespace:toInsert>
        <xsl:apply-templates/>
</xsl:template>
 
        
<xsl:template match="ownnamespace:toInsert">
        <xsl:apply-templates select="document(.)" /> 
</xsl:template>  
 
<xsl:template match="@*|node()" priority="-1">
        <xsl:copy>
              <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
</xsl:template>
</xsl:stylesheet>
 
 
--------------
 
The xsp-page which is used to call the logicsheet looks as follows
 
<?xml version="1.0" encoding="ISO-8859-1"?>
 
<xsp:page
          language="java"
          xmlns:xsp="http://apache.org/xsp"
          xmlns:ownnamespace="http://www.ownnamespace.org/xsl"
        xmlns:util="http://www.apache.org/1999/XSP/Util" 
        xmlns:xinclude="http://www.w3.org/2001/XInclude"
>
        <ownnamespace:header/>
 
  <page>
        <ownnamespace:link identifier="IDENTIFIER"/>          
  </page>
</xsp:page>


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

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