dims        01/04/03 03:26:31

  Modified:    webapp/docs/samples/slides Tag: xml-cocoon2 slides.xml
                        view-source.xsp
  Log:
  Fixed Compilation problems with view-source.xsp
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.5   +5 -5      xml-cocoon/webapp/docs/samples/slides/Attic/slides.xml
  
  Index: slides.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/webapp/docs/samples/slides/Attic/slides.xml,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- slides.xml        2000/09/08 19:36:48     1.1.2.4
  +++ slides.xml        2001/04/03 10:26:29     1.1.2.5
  @@ -319,17 +319,17 @@
      <slide>
       <title>Possible different scenarios</title>
       <ul>
  -     <li><link 
uri="view-source?filename=../docs/samples/slides/page.xml">integrated xsp 
tags</link></li>
  -     <li><link 
uri="view-source?filename=../docs/samples/slides/clean-page.xml">custom tags 
transformed by your stylesheets</link></li>
  -     <li><link 
uri="view-source?filename=../docs/samples/slides/lib-page.xml">use of cocoon 
taglibs</link></li>
  +     <li><link 
uri="view-source?filename=/docs/samples/slides/page.xml">integrated xsp 
tags</link></li>
  +     <li><link 
uri="view-source?filename=/docs/samples/slides/clean-page.xml">custom tags 
transformed by your stylesheets</link></li>
  +     <li><link 
uri="view-source?filename=/docs/samples/slides/lib-page.xml">use of cocoon 
taglibs</link></li>
       </ul>
      </slide>
   
      <slide>
       <title>Other dynamic possibilities</title>
       <ul>
  -     <li><link 
uri="view-source?filename=../docs/samples/slides/database-page.xml">SQLProcessor</link></li>
  -     <li><link 
uri="view-source?filename=../docs/samples/slides/ldap.xml">LDAPProcessor</link></li>
  +     <li><link 
uri="view-source?filename=/docs/samples/slides/database-page.xml">SQLProcessor</link></li>
  +     <li><link 
uri="view-source?filename=/docs/samples/slides/ldap.xml">LDAPProcessor</link></li>
        <li>... add yours</li>
       </ul>
      </slide>
  
  
  
  1.1.2.6   +23 -101   
xml-cocoon/webapp/docs/samples/slides/Attic/view-source.xsp
  
  Index: view-source.xsp
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/webapp/docs/samples/slides/Attic/view-source.xsp,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- view-source.xsp   2001/02/09 15:05:56     1.1.2.5
  +++ view-source.xsp   2001/04/03 10:26:30     1.1.2.6
  @@ -12,11 +12,10 @@
   
     <xsp:structure>
      <xsp:include>java.net.*</xsp:include>
  -   <xsp:include>org.apache.cocoon.xml.XMLConsumer</xsp:include>
      <xsp:include>org.apache.cocoon.xml.dom.DOMStreamer</xsp:include>
  -   
<xsp:include>org.apache.cocoon.components.language.markup.xsp.XSPUtil</xsp:include>
  -   <xsp:include>javax.servlet.ServletContext</xsp:include>
  -   <xsp:include>javax.servlet.http.HttpServletRequest</xsp:include>
  +   <xsp:include>org.apache.cocoon.xml.dom.DOMBuilder</xsp:include>
  +   <xsp:include>org.apache.cocoon.components.parser.Parser</xsp:include>
  +   <xsp:include>org.apache.cocoon.components.url.URLFactory</xsp:include>
     </xsp:structure>
   
     <xsp:logic><![CDATA[
  @@ -41,63 +40,6 @@
         ds.stream (element);
       }
   
  -
  -    protected String relativeFilename(String filename, HttpServletRequest 
request, ServletContext context)
  -        throws IOException {
  -      File file = new File(filename);
  -
  -      if (file.isAbsolute()) {
  -        return filename;
  -      }
  -
  -      return
  -        (
  -          new File(
  -            new File(
  -              getBasename(request, context)
  -            ).getParent(),
  -            filename
  -          )
  -        ).getCanonicalPath();
  -    }
  -
  -    protected String getBasename(HttpServletRequest request, Object context) 
{
  -      String path;
  -
  -      try {
  -        // detect if the engine supports at least Servlet API 2.2
  -        request.getContextPath();
  -        // we need to check this in case we've been included in a servlet or 
jsp
  -        path = (String) 
request.getAttribute("javax.servlet.include.servlet_path");
  -        // otherwise, we find it out ourselves
  -        if (path == null) path = request.getServletPath();
  -
  -        // FIXME (SM): we should use getResource() instead when we are
  -        // able to handle remote resources.
  -        String resource = ((ServletContext) context).getRealPath(path);
  -
  -        if (resource != null) {
  -          return resource.replace('\\', '/');
  -        } else {
  -          throw new RuntimeException("Cannot access non-file/war resources");
  -        }
  -      } catch (NoSuchMethodError e) {
  -        // if there is no such method we must be in Servlet API 2.1
  -        if (request.getPathInfo() != null) {
  -          // this must be Apache JServ
  -          path = request.getPathTranslated();
  -        } else {
  -          // otherwise use the deprecated method on all other servlet 
engines.
  -          path = request.getRealPath(request.getRequestURI());
  -        }
  -
  -        return (path == null) ? "" : path.replace('\\','/');
  -      } catch (NullPointerException e) {
  -        // if there is no context set, we must be called from the command 
line
  -        return request.getPathTranslated().replace('\\','/');
  -      }
  -    }
  -
       protected static DocumentFragment
         doColorize(Node node, Document factory, int level, String textColor)
       {
  @@ -280,7 +222,6 @@
   
     <html>
       <xsp:logic>
  -      Document document = parser.newDocument();
       </xsp:logic>
       <head>
         <title>Source Code</title>
  @@ -290,52 +231,33 @@
       <body>
         <xsp:logic>
           String filename = request.getParameter("filename");
  -        String resourcename = request.getParameter("url");
  -
           if (filename != null) {
  -          String filepath = null;
  -          try {
  -            filepath = relativeFilename(filename, request, (ServletContext) 
context);
  -          } catch (IOException ioe) {
  -            throw new SAXException (ioe);
  -          }
   
             <h3 style="color:navy; text-align: center">
               <xsp:expr>filename</xsp:expr>
  -          </h3>
  -
  -          InputSource is = null;
  -          try {
  -            org.apache.xerces.parsers.DOMParser parser = 
  -                        new org.apache.xerces.parsers.DOMParser();
  -            parser.parse( filepath ); 
  -            this.colorize(parser.getDocument(), document, 
this.contentHandler);
  -          } catch (FileNotFoundException fnfe) {
  -            throw new SAXException (fnfe);
  -          } catch (IOException ie) {
  -            throw new SAXException (ie);
  -          }
  -
  -        } else if (resourcename != null) {
  -          URL resource = null;
  -          try {
  -            resource = new URL(resourcename);
  -          } catch (MalformedURLException mue) {
  -            throw new SAXException (mue);
  -          }
  -
  -          <h3 style="color:navy; text-align: center">
  -            <xsp:expr>resourcename</xsp:expr>
             </h3>
  +        
  +          Parser newParser = null;
  +          URLFactory factory = null;
   
  -          InputSource is = null;
             try {
  -            is = new InputSource (resource.openStream());
  -            this.colorize(XSPUtil.getDocument(is,parser), document, 
this.contentHandler);
  -          } catch (FileNotFoundException fnfe) {
  -            throw new SAXException (fnfe);
  -          } catch (IOException ie) {
  -            throw new SAXException (ie);
  +              newParser = (Parser) this.manager.lookup(Roles.PARSER);
  +              factory = (URLFactory) 
this.manager.lookup(org.apache.cocoon.Roles.URL_FACTORY);
  +              Document document = newParser.newDocument();
  +
  +              DOMBuilder builder = new DOMBuilder(newParser);
  +              newParser.setContentHandler(builder);
  +              newParser.setLexicalHandler(builder);
  +              URL url = factory.getURL(filename);
  +              InputSource is = new InputSource(url.openStream());
  +              newParser.parse(is);
  +
  +              this.colorize(builder.getDocument(), document, 
this.contentHandler);    
  +          } catch (Exception e) {
  +              getLogger().error("Could not include page", e);
  +          } finally {
  +              this.manager.release((Component) factory);
  +              this.manager.release((Component) newParser);
             }
           } else {
             <h3 style="color:navy; text-align: center">
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to