?
Solved

Problem with XSP, nothing is displayed??

Posted on 2004-03-23
15
Medium Priority
?
541 Views
Last Modified: 2007-12-19
Hi,

When I use the following stylesheet with the following XML document in Cocoon nothing appears. The values are taken from a simple HTML file. Could someone tell me what's wrong please.
________________________________________________________________________________
tablesXSP.html:
<html>
<head>
<title>Pick a table to view using XSP</title>
</head>

<body>
<h1 align="center"><i>Choose a table</i></h1>
<center>
<form action="tablesXSP.xml" method="POST">
Table Name:
<select name="tableName">
<option value="students">Students Table</option>
<option value="subjects">Subjects Table</option>
</select>
<br/><br/><br/>
<input type="submit" value="Go"/>
</form>
</center>
</body>
</html>


________________________________________________________________________________
tablesXSP.xml:

<?xml version='1.0' encoding='ISO-8859-1'?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">

<tables>

<xsp:logic>
      boolean showStudents = true;
      boolean showSubjects = false;

      //Perform logic to get the table selected
      <![CDATA[
      String[] tableName = request.getParamaterValues("tableName");


      if(tableName!=null)
      {
            String whichTable = tableName[0];
            if(whichTable.equals("students")
            {
                  showStudents=true;
            }
            else if(whichTable.equals("subjects")
            {
                  showSubjects=true;
            }
      
      ]]>
      }


      if(showStudents)
      {
      <xsp:content>

      <table>
      <tableName>Students</tableName>
            <colDetails>
                  <colName nullable='true'>StudentID</colName>
                  <primaryKey>msg</primaryKey>
                  <colType>INTEGER</colType>
                  <colSize>11</colSize>
                  <data>
                        <value>12</value>
                                                </data>
                                                .........
                  etc.
                  <data>
                        <value>0879545123</value>
                  </data>
            </colDetails>
      </table>
      </xsp:content>
      }
      else if(showSubjects)
      {
      <xsp:content>
      <table>
      <tableName>Subjects</tableName>
            <colDetails>etc.......
      </table>
      </xsp:content>
      }
</xsp:logic>
</tables>
</xsp:page>

________________________________________________________________________________
tables2html.xsl

<?xml version="1.0"?>

<!-- CVS $Id: page2html.xsl,v 1.3 2003/05/07 19:15:51 vgritsenko Exp $ -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="tables">
   <html>
   <body>
        <center>
       <font face="arial" size="2">
       <h2>XML file in HTML form:</h2>
      
      <br></br>
      <xsl:for-each select="table">

            <table border="0" width="65%" cellpadding="6">
            <th align="left"><h4>
                                 <xsl:value-of select="tableName"/></h4></th>

                  <xsl:for-each select="colDetails">
                   <tr align="left" bgcolor="akcccc">
                              
                  <td align="center">
                        <strong><xsl:value-of select="colName"/></strong>       
                        <br><xsl:if test="primaryKey='true'">
                                  <font color="red">Primary Key</font></xsl:if></br>                                    
                        <br><i>( Size:<xsl:value-of select="colSize"/>,
                        Type:<xsl:value-of select="colType"/> )</i></br>
                  </td>
                  <xsl:for-each select="data">
                        <td><xsl:value-of select="value"/></td>
                  </xsl:for-each>
                   </tr>      
                  </xsl:for-each>
            </table>
            <br><br><br><br></br></br></br></br>
            </xsl:for-each>
      </font>
      </center>
    </body>
   </html>
  </xsl:template>
</xsl:stylesheet>

Thnaks in advance.





0
Comment
Question by:bazbazbaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
15 Comments
 
LVL 12

Expert Comment

by:dfiala13
ID: 10657802
Try this:

 <xsl:template match="xsp:page/tables">
0
 

Author Comment

by:bazbazbaz
ID: 10658641
I added that to the XSL document. The table values are still not displayed, just the heading 'XML file in HTML form' is displayed.
0
 
LVL 12

Expert Comment

by:dfiala13
ID: 10658708
Well, looking at your XML that is because table is not a child of tables. You need to account for all the nodes:

<xsp:logic>
 <xsp:content>
   <table>

Change this
<xsl:for-each select="table">

to

<xsl:for-each select="xsp:logic/xsp:content/table">
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:bazbazbaz
ID: 10658766
When I did that it gave an error: prefix must resolve to a namespace: xsp. So I took out the xsp part, but again the values weren't displayed.
0
 
LVL 12

Accepted Solution

by:
dfiala13 earned 600 total points
ID: 10658804
Need to leave in the xsp part, the prefix is part of the node name, won't find it otherwise.  You just need to tell your stylesheet how to deal with it:

Change <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


to
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsp="http://apache.org/xsp">
0
 

Author Comment

by:bazbazbaz
ID: 10658842
It now gives the error: The prefix "xsl" for element "xsl:stylesheet" is not bound. Unable to get transformer handler for XSL file.
0
 

Author Comment

by:bazbazbaz
ID: 10658876
Sorry, I actually took out the xmlns for xsl, that's why it wouldn't work. I have an xmlns for xsp and xsl now and it's working. Thanks very much.
0
 

Author Comment

by:bazbazbaz
ID: 10658904
One more question. I took out the CDATA part in the XML and hardcoded the boolean values. I have showStudents set to true and showSubjects set to false. So it should only show the student table, bit it shows both tables still. Is there anything wrong with the java in the XML document?
0
 
LVL 12

Expert Comment

by:dfiala13
ID: 10658980
You override those values later, which is what might be happening.

    String whichTable = tableName[0];
          if(whichTable.equals("students")
          {
               showStudents=true;
          }
          else if(whichTable.equals("subjects")
          {
               showSubjects=true;
          }
     

Unfortunately, I know XML/XSL but know nothing about Cocoon
0
 

Author Comment

by:bazbazbaz
ID: 10658999
Judging by the Java that I have in the XML document, do you think it should work?? Or should I put the Java in the XSL document?? Thanks again.
0
 
LVL 12

Expert Comment

by:dfiala13
ID: 10659039
Agaim, I don't know.  Never have used java in this way.  My guess would be it goes in the stylesheet.  But that is just a guess.
0
 

Author Comment

by:bazbazbaz
ID: 10659108
Can anyone else help me out on his one please, and I can split the points???
0
 

Author Comment

by:bazbazbaz
ID: 10660361
HI again,

I copied an example from the internet, and even that wont work for me. Is there something major I'm forgetting?? Is there anything sepcial that I should check for??

Cheers
0
 
LVL 15

Expert Comment

by:dualsoul
ID: 10660753
Hi bazbazbaz.
can't help you much, doesn't have much expirience with Apache Cocoon.

But try to ask in Java or JSP section. (i think Java most prefebably)
0
 

Author Comment

by:bazbazbaz
ID: 10661032
I sorted it out. In the pipeline I needed to add a type to the generate element: <map:generate type="serverpages" src="tablesXSP.xml"/>. Thanks anyway.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question