cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
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

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


---- 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=""
        <xsp:expr>"http://localhost:8080/taglib/servlet/Simple?fullname=" +

---- TestLogic.xsl ----
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    <xsl:template match="names">
        <xsl:processing-instruction name="xml-stylesheet">href="TestDisplay.xsl"
        <xsp:page language="java"
    <!-- note: if you don't include the util namespace declaration, you'll get
    cryptic "Warning: can't output text before document element!  Ignoring..." messages -->

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

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

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

---- TestDisplay.xsl ----
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    <xsl:template match="names">
                <title><xsl:value-of select="company"/></title>
            <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
                <table border="1" bgcolor="#FFFFFF" bordercolor="#000000"
cellspacing="0" cellpadding="4">
                        <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>

View raw message