You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sudheendra Hebbagilu <su...@insage.com> on 2000/10/10 23:05:43 UTC

RE: PI problem.

how does ur xml look like ? and xsl too 
~

> -----Original Message-----
> From: Monica Gupta [mailto:monica@oncr.com]
> Sent: Tuesday, October 10, 2000 7:56 PM
> To: cocoon-users@xml.apache.org
> Subject: PI problem.
> 
> 
> Hello All,
> 
> I am trying to merge XML and XSL documents (to generate a hello world
> program)thru a servlet program.
> 
> I am getting a problem.
> 
> 1) If I include the PI
> 
> <xsl:processing-instruction
> name="cocoon-format">type="text/html"</xsl:processing-instruction>
> 
> in my "xsl" file then instead of displaying the output it 
> displays the HTML
> code in the browsers with hyphens.
> 
> If i remove this PI from my xsl file then it displays word 
> hello in the
> browser and looks fine. Some how its not taking the 
> Processing Instruction.
> what should i do for PI to be effective?
> 
> Any idea whats going on?
> 
> Thanks
> 
> Monica
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 

RE: PI problem.

Posted by Monica Gupta <mo...@oncr.com>.
Thanks for the response. Actually whatever is written between
<xsp:logic></xsp:logic> tags just gets displayed as text in the output.

Here is the output of my program:
_________________________________

String xmlStr = "hello" ;

Hello
This isxmlStrpage!



The following are the 3 files used

hello.xml
____________

<?xml version="1.0"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="XSL/hello.xsl" type="text/xsl"?>
<xsp:page language="java" xmlns:xsp="http://www.apache.org/1999/XSP/Core">
  <page>
    <xsp:logic>String xmlStr = "hello" ;</xsp:logic>
    <title>Hello</title>
    <content>
      <paragraph>This is<xsp:expr>xmlStr</xsp:expr>page!</paragraph>
    </content>
  </page>
</xsp:page>

hello.xsl
_________

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="page">
    <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
    <html>
      <head>
        <title>
          <xsl:value-of select="title"/>
        </title>
      </head>
      <body bgcolor="#ffffff">
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="title">
    <h1 align="center">
      <xsl:apply-templates/>
    </h1>
  </xsl:template>
  <xsl:template match="paragraph">
    <p align="center">
      <i>
        <xsl:apply-templates/>
      </i>
    </p>
  </xsl:template>
</xsl:stylesheet>


first.java
__________


import org.apache.xalan.xslt.XSLTProcessor;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTResultTarget;


import org.apache.xalan.xslt.* ;
import org.apache.xalan.* ;

import org.xml.sax.*;

import org.* ;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class first1 extends HttpServlet
  {


  public void init(ServletConfig config) throws ServletException
    {
      super.init(config) ;
    }

  public void service(HttpServletRequest servReq, HttpServletResponse
servRes) throws
      IOException
   {


     servRes.setContentType("text/html") ;
     String sheet =
"d:\\jakarta\\jakarta-tomcat\\webapps\\cocoon\\xml\\xsl\\hello.xsl" ;
     String doc =
"d:\\jakarta\\jakarta-tomcat\\webapps\\cocoon\\xml\\hello.xml" ;

     System.err.println("first.service -- entered");

     try{
          XSLTProcessor processor = XSLTProcessorFactory.getProcessor() ;
          processor.process(new XSLTInputSource(new FileInputStream(doc)) ,
			  new XSLTInputSource(new FileInputStream(sheet)) ,
                            new
XSLTResultTarget(servRes.getOutputStream()));
               System.err.println("second.service -- entered");
        }

     catch (Exception e )
       {
          PrintWriter out = servRes.getWriter() ;
          out.println("Error:"+ e ) ;
          out.close() ;
        }
    }
}
-----Original Message-----
From: Sudheendra Hebbagilu [mailto:sudheendra@insage.com]
Sent: Tuesday, October 10, 2000 2:06 PM
To: 'cocoon-users@xml.apache.org'
Subject: RE: PI problem.


how does ur xml look like ? and xsl too
~

> -----Original Message-----
> From: Monica Gupta [mailto:monica@oncr.com]
> Sent: Tuesday, October 10, 2000 7:56 PM
> To: cocoon-users@xml.apache.org
> Subject: PI problem.
>
>
> Hello All,
>
> I am trying to merge XML and XSL documents (to generate a hello world
> program)thru a servlet program.
>
> I am getting a problem.
>
> 1) If I include the PI
>
> <xsl:processing-instruction
> name="cocoon-format">type="text/html"</xsl:processing-instruction>
>
> in my "xsl" file then instead of displaying the output it
> displays the HTML
> code in the browsers with hyphens.
>
> If i remove this PI from my xsl file then it displays word
> hello in the
> browser and looks fine. Some how its not taking the
> Processing Instruction.
> what should i do for PI to be effective?
>
> Any idea whats going on?
>
> Thanks
>
> Monica
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>

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