cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sreedhar Chintalapaty" <schintalap...@ptc.com>
Subject RE: Including a page with custom tags
Date Wed, 20 Mar 2002 16:03:46 GMT
GlacierSmall correction: the logic sheet is as follows:
Tag in the Logicsheet:
  <xsl:template match="singertags:get-name">
      Elvis Presley
  </xsl:template>
Also, I have verified that, by accessing featuredArticle.xml directly with
the following match, that the logic sheet works and that featuredArticle.xml
has the right syntax.
  <map:match pattern="xsp/fa">
      <map:generate type="serverpages"
src="content/current/featuredArticle.xml"/>
      <map:serialize type="xml"/>
  </map:match>
Accessing http://<myAppBase>/xsp/fa results in "Singer Name: Elvis Presley"
being displayed in the browser.

I also tried XInclude in menupage.xsl, that also gets sent out verbatim to
the browser.

Sreedhar
  -----Original Message-----
  From: Sreedhar Chintalapaty [mailto:schintalapaty@ptc.com]
  Sent: Wednesday, March 20, 2002 10:24 AM
  To: Cocoon Users
  Subject: Including a page with custom tags


  Another newbie question that I could not find an answer for in the
archives.

  Part of my web site needs to generate dynamic content based on database
queries. I intend to write my own logicsheets to get that functionality (I
am not using ESQL because I need to talk to my java model, not directly to
the database ).

  I used Bonebreaker application as the learning tool so far; my web page is
divvied up into a few sections in terms of layout:
    Menu at the top
    Toolbar on the left side
    Content on the prime real estate
  To provide static content, I pass the name of the file to be shown in the
request (e.g.
http://<myAppBase>/current/welcome.html?show=content/current/featuredArticle
). In the xsl style sheet which processes this (menupage.xsl in
bonebreaker), I use the (pre-existing) xsl:copy-of call to just get
everything from the static xml file featuredArticle.xml.

  So far, this works fine.

  Now, to provide the dynamic content, I put in a call to a custom tag in
the featuredArticle.xml file, like so:
      <singertags:get-name/>

  The tag <singertags:get-name/> takes no parameters; it is just supposed to
print "Elvis Presley".

  I registered the tag file in cocoon.xconf. It seems to be loading fine
(from what I see in core.log)

  The trouble is: I don't know how to make cocoon actually process the tag.
This has something to do with Sitemap, but I don't know what I should put in
there. What I have now is this:

  Sitemap:
      <map:match pattern="xsp/**">
          <map:generate type="serverpages" src="{1}{requestQuery}"/>
          <map:transform type="cinclude"/>
          <map:serialize/>
      </map:match>

      <map:match pattern="*/*.**">
          <map:act type="request">
              <map:parameter name="parameters" value="true"/>
              <map:generate type="request"
src="control/{../1}/{../2}.xml{requestQuery}"/>
              <map:transform type="xslt" src="view/xsl/{../3}/content.xsl">
                  <map:parameter name="use-request-parameters"
value="true"/>
                  <map:parameter name="tab" value="{../1}"/>
                  <map:parameter name="topic" value="{topic}"/>
                  <map:parameter name="subtopic" value="{../2}"/>
                  <map:parameter name="tabs"
value="../../../control/config/tabs.xml"/>
                  <map:parameter name="topics"
value="../../../control/config/{../1}.xml"/>
                  <map:parameter name="base-url" value="/cocoon/gvs"/>
              </map:transform>
              <map:transform type="xslt" src="view/xsl/{../3}/menupage.xsl">
                  <map:parameter name="use-request-parameters"
value="true"/>
                  <map:parameter name="tab" value="{../1}"/>
                  <map:parameter name="topic" value="{topic}"/>
                  <map:parameter name="subtopic" value="{../2}"/>
                  <map:parameter name="request-url"
value="../../../{show}.xml"/>
                  <map:parameter name="tabs"
value="../../../control/config/tabs.xml"/>
                  <map:parameter name="topics"
value="../../../control/config/{../1}.xml"/>
                  <map:parameter name="css-stylesheet" value="default.css"/>
                  <map:parameter name="base-url" value="/cocoon/gvs"/>
              </map:transform>
              <map:serialize/>
          </map:act>
      </map:match>

  Tag in the Logicsheet:
    <xsl:template match="singertags:get-name">
        <xsp:expr>
            Elvis Presley
        </xsp:expr>
    </xsl:template>
  FeaturedArticle.xml:

    <xsp:page xmlns:xsp="http://apache.org/xsp"
xmlns:singertags="http://gvs/singertags">
        <page>
            Singer Name: <singertags:get-name/>
        </page>
    </xsp:page>
  Menupage.xsl:

    <!-- The following line prints non-tag stuff if <xsp:page> tags are
removed from featuredArticle.xml -->
    <xsl:copy-of select="document($request-url)/page"/>

    <!-- Does not work regardless: just sends this out in toto to the
browser (which will ignore it) -->
    <cinclude:include src="xsp/{$request-url}"/>
    <xsl:apply-templates select="./article"/>
  The Problem:

  Instead of printing "Singer Name: Elvis Presley", it just prints nothing.
If I take out the <xsp:page> tags from featuredArticle.xml, it prints
"Singer Name:" and leaves a blank in place of the tag. Obviously I am doing
something wrong (or not doing something) and this must be a fairly dumb
question...

  I would appreciate if someone can point me in the right direction... (I
try to compensate for my lack of originality with copying skills ;))

  Best Regards,

  Sreedhar Chintalapaty

____________________________________________________________________________
______________
  A computer is like an Old Testament god, with a lot of rules and no
mercy - Joseph Campbell



Mime
View raw message