cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@socialchange.net.au
Subject RE: Bugs!
Date Fri, 29 Dec 2000 05:17:41 GMT


> Thanks.  That helped a little bit but not quite.  If you look at my example
> I go from testloader.xml to testlogic.xsl to testdisplay.xsl.  The purpose
> of testlogic and testdisplay is to split the logic processing from the
> presentation.

Ah right. You're using the 'clean page model' (see samples/xsp/clean-page.xml),
only you're not doing it properly.

First off, I think your second 'bug' was that pages weren't reloading until you
blew away the repository. In the clean page model, you must touch the source
XML document (TestLoader.xml) *every time* you make a change to the
stylesheets (TestLogic.xsl). It's very easy to forget.

In the clean page model, you use stylesheets to convert user-defined XML into an
XSP page. By contrast, in the taglib model, you use stylesheets (taglibs) to pull in
bits of XSP into an already-existing XSP page. From what I gather, the clean page
model is deprecated in C1 and won't work in C2. But anyway..

What you're doing wrong is invoking the XSP processor in TestLoader.xml (content)
and in TestLogic.xsl (logic). You should only be doing it in TestLogic.xsl.

If you have a look at samples/xsp/clean-page.xml, there are only 2 PIs are the top:

<?cocoon-process type="xslt"?>
<?xml-stylesheet href="page-xsp.xsl" type="text/xsl"?>

Ie, "take this XML and run it through "page-xsp.xsl". We don't know or care at this stage
what to do with the output.

Then in page-xsp.xsl (your TestLogic.xsl), we have:

<xsl:processing-instruction name="cocoon-process">type="xsp"</xsl:processing-instruction>
<xsl:processing-instruction name="cocoon-process">type="xslt"</xsl:processing-instruction>
<xsl:processing-instruction name="xml-stylesheet">href="page-html.xsl" type="text/xsl"</xsl:processing-instruction>

So the output document will include PIs that invoke the XSP processor, and the XSLT formatter.
Note: for testing, you might want to replace the second two tags with:

<xsl:processing-instruction name="cocoon-format">type="text/xml"</xsl:processing-instruction>

So we can worry about one thing at a time.

That gets the pipeline working, and I'm sure you can take it from there. Btw, 
one nice thing about the clean page model is that you can 'simulate' the first
step (converting XML to XSP) by hand, and see if the result is decent-looking
XSP.

I'll [snip] the rest of the post, and include working modifications of your code.

--Jeff


---- TestLoader.xml ----
<?xml version="1.0"?>
<!-- ?cocoon-process type="xsp"? -->
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="TestLogic.xsl" type="text/xsl"?>

<xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core"
              xmlns:util="http://www.apache.org/1999/XSP/Util">
     <names>
      <util:include-uri>
    <util:href>
        <xsp:expr>"http://localhost:8080/taglib/servlet/Simple?fullname=" +
request.getParameter("fullname")</xsp:expr>
    </util:href>
      </util:include-uri>
     </names>
</xsp:page> 
----

---- TestLogic.xsl ----
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xsp="http://www.apache.org/1999/XSP/Core">
        
    <xsl:template match="names">
        <xsl:processing-instruction
name="cocoon-process">type="xsp"</xsl:processing-instruction>
        <xsl:processing-instruction
name="cocoon-process">type="xslt"</xsl:processing-instruction>
        <xsl:processing-instruction name="xml-stylesheet">href="TestDisplay.xsl"
type="text/xsl"</xsl:processing-instruction>
        <xsp:page language="java"
          xmlns:xsp="http://www.apache.org/1999/XSP/Core"
          xmlns:util="http://www.apache.org/1999/XSP/Util"
        >                   
    <!-- note: if you don't include the util namespace declaration, you'll get
    cryptic "Warning: can't output text before document element!  Ignoring..." messages -->

            <page>
                <xsl:copy-of select="*"/> <!-- let through XSP in content -->
            </page>
        </xsp:page>
    </xsl:template>

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

    <xsl:template match="fullname">
        <xsl:copy-of select="."/>
    </xsl:template>
</xsl:stylesheet>
----


---- TestDisplay.xsl ----
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="names">
        <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
        <html>
            <head>
                <title><xsl:value-of select="company"/></title>
            </head>
            <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
                <table border="1" bgcolor="#FFFFFF" bordercolor="#000000"
cellspacing="0" cellpadding="4">
                    <tr>
                        <td align="center" valign="middle" bgcolor="#C0C0C0">
                            <big><big><xsl:value-of select="company"/><xsl:text>
</xsl:text><xsl:value-of select="fullname"/></big></big>
                        </td>
                    </tr>
                </table>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>
----


Mime
View raw message