You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Falk, Dave K." <Da...@pearson.com> on 2003/07/31 20:20:55 UTC

newbie question: problem with logicsheets

Let me preface my question(s) by saying that I am totally new to cocoon - I
just downloaded and installed
it 2 days ago.  I have a fair amount of Java and some XML experience;
However, I am trying to learn some
of the related technologies (XSLT, XSP, XPATH, etc...).  The problem I am
having is in attempting to
run an example from Oreilly's Java and XML book.  I am including all
relevant files (they're short) in the
hopes someone out there can explain to me why I'm getting the following
error:  FWIW, I am using
Cocoon 2.1rc1 with Jdk 1.4.2.  

org.apache.cocoon.ProcessingException: Language Exception:
org.apache.cocoon.components.language.LanguageException: Error compiling
chapterTenXSP_xml:
ERROR 1 (org\apache\cocoon\www\samples\Javaxml2\chapterTenXSP_xml.java):
...

// start error (lines 1-1) "The declared package does not match the expected
package org.apache.cocoon.www.samples.Javaxml2"


// end error

package ; 

import java.io.File; 

...

Files to follow
--------------------
Source XML file (chapterTenXSP.xml)
<?xml version="1.0"?>

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

<xsp:page language="java"
          xmlns:xsp="http://apache.org/xsp"
          xmlns:javaxml2="http://www.oreilly.com/javaxml2"
>

<xsp:logicsheet location="XSL/JavaXML.xsp.xsl"/> 

<book>
 <cover>
  <title>Java and XML</title>
  <author>Brett McLaughlin</author>
 </cover>

 <contents>
  <chapter title="Web Publishing Frameworks" number="10">
    <javaxml2:draftTitle chapterNum="10"
                         chapterTitle="Web Publishing Framework" />
      
   <paragraph> This chapter begins looking at specific Java and XML 
topics. So far, I have covered the basics of using XML from Java, 
looking at the SAX, DOM, JDOM, and JAXP APIs to manipulate XML and the 
fundamentals of using and creating XML itself. Now that you have a grasp 
on using XML from your code, I want to spend time on specific 
applications. The next six chapters represent the most significant 
applications of XML, and, in particular, how those applications are 
implemented in the Java space. While there are literally thousands of 
important applications of XML, the topics in these chapters are those 
that continually seem to be in the spotlight, and that have a significant
potential to change the way traditional development processes occur. 
   </paragraph>

   <xsp:logic>
    boolean authorOrEditor = false;

    // Perform logic to see if user is an author or editor
 <![CDATA[
 String[] roleValues = request.getParameterValues("userRole");
 String[] passwordValues = request.getParameterValues("password");
 if ((roleValues != null) && (passwordValues != null)) {
   String userRole = roleValues[0];
   String password = passwordValues[0];
   if (userRole.equals("author") && password.equals("brett")) {
     authorOrEditor = true;
   } else
     if (userRole.equals("editor") && password.equals("mike")) {
     authorOrEditor = true;
   }
 }
 ]]>
    
    if (authorOrEditor) {
      <xsp:content>   
        <authorComment>Mike - Do you think the following sidebar is 
        a little much? I could easily leave it out if it's still 
        clear without it.</authorComment>
      </xsp:content>
    }
   </xsp:logic>
   

    <sidebar title="The More Things Change, the More They Stay the Same">
Readers of the first edition of this book will find that 
much of this chapter on Cocoon is the same as the first edition. Although
I promised you that Cocoon 2 would be out by now, and although I expected
to be writing a chapter on Cocoon 2, things haven't progressed as quickly
as expected. Stefano Mazzochi, the driving force behind Cocoon, finally 
got around to finishing school (good choice, Stefano!), and so 
development on Cocoon 2 has significantly slowed. The result is that 
Cocoon 1.x is still the current development path, and you should stick 
with it for now. I've updated the section on Cocoon 2 to reflect what is 
coming, and you should keep an eye out for more Cocoon-related books from
O'Reilly in the months to come.</sidebar>

   <paragraph> I'll begin this look at hot topics with the one XML 
application that seems to have generated the largest amount of excitement
in the XML and Java communities: the web publishing framework. Although 
I have continually emphasized that generating presentation from content 
is perhaps over-hyped when compared to the value of the portable data 
that XML provides, using XML for presentation styling is still very 
important. This importance increases when looking at web-based 
applications.</paragraph>
  </chapter>

 </contents>
</book>
</xsp:page>


Logicsheet (XSL/JavaXML.xsp.xsl)
<?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:javaxml2="http://www.oreilly.com/javaxml2"
>
  <xsl:template match="xsp:page">
    <xsp:page>
      <xsl:copy>
        <xsl:apply-templates select="@*"/>
      </xsl:copy>

      <xsp:structure>
        <xsp:include>java.util.Date</xsp:include>
        <xsp:include>java.text.SimpleDateFormat</xsp:include>
      </xsp:structure>

      <xsp:logic>
        private static String getDraftDate() {
          return (new SimpleDateFormat("MM/dd/yyyy"))
            .format(new Date());
        }

        private static String getTitle(int chapterNum, 
                                       String chapterTitle) {
          return chapterNum + ". " + chapterTitle;
        }
      </xsp:logic>

      <xsl:apply-templates/>
    </xsp:page>
  </xsl:template>
  
  <!-- Create formatted title -->
  <xsl:template match="javaxml2:draftTitle">
    <xsp:expr>getTitle(<xsl:value-of select="@chapterNum" />,
                       "<xsl:value-of select="@chapterTitle" />")
    </xsp:expr> (<xsp:expr>getDraftDate()</xsp:expr>)
  </xsl:template>

  <xsl:template match="@*|*|text()|processing-instruction()">
    <xsl:copy>
      <xsl:apply-templates 
           select="@*|*|text()|processing-instruction()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>


Thank you in advance for any help regarding this matter,
  Dave




**************************************************************************** 
This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
****************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org