cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Gritsenko" <vadim.gritse...@verizon.net>
Subject RE: xinclude of xsp-file inside xsp-file?
Date Wed, 08 May 2002 14:43:59 GMT
> From: Jerzy Kut [mailto:jerzyk@rzeszow.tiger.com.pl]
> 
> Thank You. I see it is possible and quite nice. I had got problems
with my
> own components and I decided to write own logicsheets, but I spent
much time
> on looking for dynamical parameter passing errors. But now I resolve
it with
> huge help of this list users. Thank You. But I have some troubles with
> universal passing parameters (i mean static and dynamic) in my own
> logicsheets. I mean trouble with <xsl:copy-of> and <xsl:value-of> tags
and
> with <xsp:expr>. When I pass static parameters all works good. But
with
> dynamical parameters logicsheet need to be written in another way.

Logicsheet authoring differs from writing plain XSLT...


> But I
> have small experience in writting cocoon applications and XSLT. Is
there any
> method of writting universal logicsheets that can be nested as I wish?
Need
> I strong use of JAVA code (I don't afraid of it, but I wish my
component
> should be easy used by XML creators)?

No. You just need to know couple of tricks and apply them everywhere.
Let's take a look at the request logicsheet:

...
  <xsl:template match="xsp-request:get-parameter">
    <xsl:variable name="name">
      <xsl:call-template name="value-for-name"/>
    </xsl:variable>
...
  <xsl:template name="value-for-name">
    <xsl:choose>
      <xsl:when test="@name">"<xsl:value-of select="@name"/>"</xsl:when>
      <xsl:when test="xsp-request:name">
        <xsl:call-template name="get-nested-content">
          <xsl:with-param name="content" select="xsp-request:name"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>null</xsl:otherwise>
    </xsl:choose>
  </xsl:template>
...
  <xsl:template name="get-nested-content">
    <xsl:param name="content"/>
    <xsl:choose>
      <xsl:when test="$content/xsp:text">"<xsl:value-of
select="$content"/>"</xsl:when>
      <xsl:when test="$content/*">
        <xsl:apply-templates select="$content/*"/>
      </xsl:when>
      <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
    </xsl:choose>
  </xsl:template>


Snippets above show how to make @name attribute on
xsp-request:get-parameter template. Usage of the template written like
this can be static *and* dynamic (all snippets below should work on
2.0.3):

<xsp-request:get-parameter name="a"/>

<xsp-request:get-parameter>
  <xsp-request:name>a</xsp-request:name>
</xsp-request:get-parameter>

<xsp-request:get-parameter>
  <xsp-request:name><xsp:expr>"a"</xsp:expr></xsp-request:name>
</xsp-request:get-parameter>

<xsp:logic>
  String sName = "a";
  <xsp-request:get-parameter>
    <xsp-request:name><xsp:expr>sName</xsp:expr></xsp-request:name>
  </xsp-request:get-parameter>
</xsp:logic>



In the main XSP logicsheet, things implemented a bit differently, with
the use of get-parameter template (see xsp.xsl for the definition of
this template):

...
  <xsl:template match="xsp:element">
    <xsl:variable name="uri">
      <xsl:call-template name="get-parameter">
        <xsl:with-param name="name">uri</xsl:with-param>
      </xsl:call-template>
    </xsl:variable>
...


Usage of template written with get-parameter could be:

<xsp:element uri="a" .../>

<xsp:element ...>
  <xsp:param name="uri">a</xsp:param>
</xsp:element>

<xsp:element>
  <xsp:param name="uri"><xsp:expr>"a"</xsp:expr></xsp:param>
</xsp:element>

<xsp:logic>
  String sURI = "a";
  <xsp:element>
    <xsp:param name="uri"><xsp:expr>sURI</xsp:expr></xsp:param>
  </xsp:element>
</xsp:logic>

PS: I'm CC-ing user list as this info might be useful to others.

Vadim


> I know this explanation can be a little obscure...
> Best regards
> Jerzy Kut
> 
> ----- Original Message -----
> From: "Vadim Gritsenko" <vadim.gritsenko@verizon.net>
> To: <cocoon-users@xml.apache.org>
> Sent: Wednesday, May 08, 2002 3:51 PM
> Subject: RE: xinclude of xsp-file inside xsp-file?
> 
> 
> > > From: Jerzy Kut [mailto:jerzyk@rzeszow.tiger.com.pl]
> > >
> > > I agree with Volker. I think it will be good facilitation when the
> > > serverpages can be aggregating directly (not called by HTTP URL
like
> > > "http://my.domain/cocoon/my.service/doc.xml", but as
> >
> > Never use http as long as resource resides in the same Cocoon
instance.
> > That's just not effective.
> >
> >
> > > <map:part src="doc.xsp" type="serverpages"/> like generators).
> >
> > Define internal pipeline serving XSPs, and use it in your map:parts.
> > <map:part/> is really not a generator, but just specifies where to
get
> > the source of the part. And you can point to any pipeline,
containing
> > XSP, and/or aggregation(s), multiple transformations, etc.
> >
> >
> > > And maybe it will be good to define XSP as Transformer...
> >
> > It doesn't worth the effort. If you think otherwise - you can
implement
> > it :)
> >
> >
> > > I know - we have logicsheets,
> > > but it is quite hard to pass dynamic parameters between them.
> >
> > Do you really think so? All templates are written long time ago,
just
> > reuse them.
> >
> > Combining this and previous sentence, I guess you want to create XSP
> > source dynamically, generating XSP source code depending on input
> > parameters. If it is so, I think you fail to anticipate the fact
that
> > this will require recompilation of the page every time you specify
> > different input parameters. However with logicsheets, you are able
to
> > achieve same results with just one compiled version of the XSP page.
> >
> > Vadim
> >
> > > I think it
> > > would be good when we could setup a few serverpages as
transformers.
> > > What do
> > > You mean Vadim?
> > > Best regards
> > > Jerzy Kut
> > >
> > > ----- Original Message -----
> > > From: "Volker Schneider" <volker.schneider@danet.de>
> > > To: <cocoon-users@xml.apache.org>
> > > Sent: Wednesday, May 08, 2002 3:06 PM
> > > Subject: RE: xinclude of xsp-file inside xsp-file?
> > >
> > >
> > > > Hi Vadim,
> > > >
> > > > thank you for your reply.
> > > >
> > > > I want to include the results of several xsp-Pages (xml) into
> > > > another
> > > > xsp-page which then can be compiled again and results xml.
> > > >
> > > > I think about several ServerPagesGenerators which produces xml
(not
> > > > files)
> > > > which can be included into an xsp-File in order to result the
final
> > > > xml.
> > > >
> > > > It's the xinclude mechanism but it includes no static xml files
but
> > > > dynamic
> > > > xsp-generated xml's. Because of performance I want to avoid
writing
> > > > intermediate xml files.
> > > >
> > > > Best regards
> > > > - Volker -
> > > >
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: Vadim Gritsenko [mailto:vadim.gritsenko@verizon.net]
> > > > Sent: Mittwoch, 8. Mai 2002 14:51
> > > > To: cocoon-users@xml.apache.org
> > > > Subject: RE: xinclude of xsp-file inside xsp-file?
> > > >
> > > >
> > > > > From: Volker Schneider [mailto:volker.schneider@danet.de]
> > > > >
> > > > > Dear colleagues,
> > > > >
> > > > > is it possible to use xinclude inside xsp-Files, where the
> > > > > included
> > > > > files
> > > > > are xsp-files itself`?
> > > > >
> > > > > The problem is that 2 or more dynamic xsp-components should be
> > > > > included into
> > > > > another xsp-file?
> > > > >
> > > > > Is something like that possible, so that all xsp's (the parent
and
> > > > > the
> > > > > included) will be compiled?
> > > >
> > > > What do you want to do - to include result of execution of
several
> > > > XSP
> > > > pages into XML generated by other XSP page, or to create XSP
page
> > > > source
> > > > by combining result of execution of other XSP pages, or to
create
> > > > XSP
> > > > page source by combining it from several parts?
> > > >
> > > > Vadim
> > > >
> > > > > An XInclude generator and ServerPagesTransformer
> > > > > would do that, but they do not exist.
> > > > >
> > > > > Thank you, best regards
> > > > > - Volker -


---------------------------------------------------------------------
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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message