cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@locus.apache.org
Subject cvs commit: xml-cocoon/webapp/docs/samples/slides view-source.xsp
Date Fri, 08 Sep 2000 14:00:35 GMT
giacomo     00/09/08 07:00:34

  Modified:    webapp/docs/samples/slides Tag: xml-cocoon2 view-source.xsp
  Log:
  fixed a little bug
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +349 -349  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.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- view-source.xsp	2000/09/07 22:48:19	1.1.2.1
  +++ view-source.xsp	2000/09/08 14:00:30	1.1.2.2
  @@ -1,349 +1,349 @@
  -<?xml version="1.0"?>
  -<!-- Written by Ricardo Rocha <rrocha@plenix.org> -->
  -
  -<!-- A quick'n'dirty XML colorizer -->
  -
  -
  -<xsp:page
  -          language="java"
  -          xmlns:xsp="http://apache.org/xsp"
  ->
  -
  -  <xsp:structure>
  -   <xsp:include>java.net.*</xsp:include>
  -   <xsp:include>org.apache.cocoon.components.parser.XercesParser</xsp:include>
  -   <xsp:include>org.apache.cocoon.xml.XMLConsumer</xsp:include>
  -   <xsp:include>org.apache.cocoon.xml.util.DOMStreamer</xsp:include>
  -   <xsp:include>org.apache.cocoon.util.DOMUtils</xsp:include>
  -   <xsp:include>javax.servlet.ServletContext</xsp:include>
  -   <xsp:include>javax.servlet.http.HttpServletRequest</xsp:include>
  -  </xsp:structure>
  -  
  -  <xsp:logic><![CDATA[
  -    private static final String ATTR_NAME_COLOR = "darkblue";
  -    private static final String ATTR_VALUE_COLOR = "navy";
  -    private static final String COMMENT_COLOR = "gray";
  -    private static final String DELIMITER_COLOR = "blue";
  -    private static final String ELEMENT_COLOR = "navy";
  -    private static final String ENTITY_REF_COLOR = "navy";
  -    private static final String PI_COLOR = "darkred";
  -    private static final String TEXT_COLOR = "black";
  -    private static final String CUSTOM_ELEMENT_COLOR = "green";
  -    private static final String XSL_ELEMENT_COLOR = "purple";
  -    private static final String XSP_ELEMENT_COLOR = "green";
  -    private static final String XSP_TEXT_COLOR = "red";
  -
  -    private XercesParser xercesParser = new XercesParser();
  -
  -    protected void colorize(Node node, Document factory, org.xml.sax.ContentHandler contentHandler)
throws SAXException {
  -      Element element = factory.createElement("pre");
  -      DocumentFragment fragment = factory.createDocumentFragment();
  -      element.appendChild(doColorize(node, factory, 0, TEXT_COLOR));
  -      DOMStreamer ds = new DOMStreamer (contentHandler);
  -      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)
  -    {
  -      Element result = null;
  -      DocumentFragment fragment = factory.createDocumentFragment();
  -
  -      switch (node.getNodeType()) {
  -        case Node.CDATA_SECTION_NODE:
  -          result = factory.createElement("font");
  -          result.setAttribute("color", DELIMITER_COLOR);
  -          result.appendChild(factory.createTextNode("<![CDATA["));
  -          fragment.appendChild(result);
  -
  -          result = factory.createElement("font");
  -          result.setAttribute("color", textColor);
  -          result.appendChild(factory.createTextNode(node.getNodeValue()));
  -          fragment.appendChild(result);
  -
  -          result = factory.createElement("font");
  -          result.setAttribute("color", DELIMITER_COLOR);
  -          // I know the thing below is ugly, but man, nexted CDATA are a pain in the ass!
  -          result.appendChild(factory.createTextNode("]]]]>&gt;<![CDATA["));
  -          fragment.appendChild(result);
  -
  -          break;
  -        case Node.ELEMENT_NODE: {
  -          Element element = (Element) node;
  -  
  -          result = factory.createElement("font");
  -          result.setAttribute("color", DELIMITER_COLOR);
  -          result.appendChild(factory.createTextNode("<"));
  -          fragment.appendChild(result);
  -
  -          String tagColor = ELEMENT_COLOR;
  -          String tagName = element.getTagName();
  -
  -          if (tagName.startsWith("xsp:")) {
  -            tagColor = XSP_ELEMENT_COLOR;
  -          } else if (tagName.startsWith("xsl:")) {
  -            tagColor = XSL_ELEMENT_COLOR;
  -          } else if (tagName.indexOf(':') >= 0) {
  -            tagColor = CUSTOM_ELEMENT_COLOR;
  -          }
  -
  -          result = factory.createElement("font");
  -          result.setAttribute("color", tagColor);
  -          result.appendChild(factory.createTextNode(tagName));
  -          fragment.appendChild(result);
  -
  -          NamedNodeMap attributes = element.getAttributes();
  -          int attributeCount = attributes.getLength();
  -  
  -          for (int i = 0; i < attributeCount; i++) {
  -            Attr attribute = (Attr) attributes.item(i);
  -  
  -            result = factory.createElement("font");
  -            result.setAttribute("color", ATTR_NAME_COLOR);
  -            result.appendChild(
  -              factory.createTextNode(" " + attribute.getName() + "=")
  -            );
  -            fragment.appendChild(result);
  -
  -            result = factory.createElement("font");
  -            result.setAttribute("color", ATTR_VALUE_COLOR);
  -            result.appendChild(
  -              factory.createTextNode("\"" + attribute.getValue() + "\"")
  -            );
  -            fragment.appendChild(result);
  -          }
  -  
  -          NodeList nodeList = element.getChildNodes();
  -          int childCount = nodeList.getLength();
  -  
  -          result = factory.createElement("font");
  -          result.setAttribute("color", DELIMITER_COLOR);
  -          result.appendChild(
  -            factory.createTextNode((childCount == 0 ? "/" : "") + ">")
  -          );
  -          fragment.appendChild(result);
  -
  -          if (tagName.startsWith("xsp:")) {
  -            textColor = XSP_TEXT_COLOR;
  -          } else {
  -            textColor = TEXT_COLOR;
  -          }
  -            
  -          result = factory.createElement("font");
  -          result.setAttribute("color", textColor);
  -
  -          for (int i = 0; i < childCount; i++) {
  -            result.appendChild(
  -              doColorize(nodeList.item(i), factory, level + 1, textColor)
  -            );
  -          }
  -          fragment.appendChild(result);
  -
  -          if (childCount > 0) {
  -            result = factory.createElement("font");
  -            result.setAttribute("color", DELIMITER_COLOR);
  -            result.appendChild(factory.createTextNode("</"));
  -            fragment.appendChild(result);
  -
  -            result = factory.createElement("font");
  -            result.setAttribute("color", tagColor);
  -            result.appendChild(factory.createTextNode(tagName));
  -            fragment.appendChild(result);
  -
  -            result = factory.createElement("font");
  -            result.setAttribute("color", DELIMITER_COLOR);
  -            result.appendChild(factory.createTextNode(">"));
  -            fragment.appendChild(result);
  -          }
  -  
  -          break;
  -        }
  -        case Node.DOCUMENT_NODE:
  -        case Node.DOCUMENT_FRAGMENT_NODE: {
  -          NodeList nodeList = node.getChildNodes();
  -          int childCount = nodeList.getLength();
  -  
  -          for (int i = 0; i < childCount; i++) {
  -            fragment.appendChild(
  -              doColorize(nodeList.item(i), factory, level + 1, textColor)
  -            );
  -          }
  -  
  -          break;
  -        }
  -        case Node.COMMENT_NODE:
  -          result = factory.createElement("font");
  -          result.setAttribute("color", COMMENT_COLOR);
  -
  -          result.appendChild(
  -            factory.createTextNode(
  -              "<!-- " + node.getNodeValue() + " -->\n"
  -            )
  -          );
  -
  -          fragment.appendChild(result);
  -
  -          break;
  -        case Node.PROCESSING_INSTRUCTION_NODE:
  -          ProcessingInstruction pi = (ProcessingInstruction) node;
  -
  -          result = factory.createElement("font");
  -          result.setAttribute("color", DELIMITER_COLOR);
  -          result.appendChild(factory.createTextNode("<?"));
  -          fragment.appendChild(result);
  -  
  -          result = factory.createElement("font");
  -          result.setAttribute("color", PI_COLOR);
  -          result.appendChild(factory.createTextNode(pi.getTarget() + " " + pi.getData()));
  -          fragment.appendChild(result);
  -  
  -          result = factory.createElement("font");
  -          result.setAttribute("color", DELIMITER_COLOR);
  -          result.appendChild(factory.createTextNode("?>\n"));
  -          fragment.appendChild(result);
  -
  -          break;
  -        case Node.ENTITY_REFERENCE_NODE:
  -          result = factory.createElement("font");
  -          result.setAttribute("color", ENTITY_REF_COLOR);
  -          result.appendChild(
  -            factory.createTextNode("<" + node.getNodeValue() + ";")
  -          );
  -          fragment.appendChild(result);
  -
  -          break;
  -        case Node.TEXT_NODE:
  -          fragment.appendChild(factory.createTextNode(node.getNodeValue()));
  -          break;
  -        default:
  -          break;
  -      }
  -
  -      return fragment;
  -    }
  -  ]]></xsp:logic>
  -
  -  <html>
  -    <xsp:logic>
  -      Document document = xercesParser.newDocument();
  -    </xsp:logic>
  -    <head>
  -      <title>Source Code</title>
  -      <link rel="stylesheet" type="text/css" href="style" title="Style"/>
  -    </head>
  -
  -    <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 {
  -            is = new InputSource (new FileReader (filepath));
  -            this.colorize(DOMUtils.DOMParse(is), 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>
  -      
  -          InputSource is = null;
  -          try {
  -            is = new InputSource (resource.openStream());
  -            this.colorize(DOMUtils.DOMParse(is), document, this.contentHandler);
  -          } catch (FileNotFoundException fnfe) {
  -            throw new SAXException (fnfe);
  -          } catch (IOException ie) {
  -            throw new SAXException (ie);
  -          }
  -        } else {
  -          <h3 style="color:navy; text-align: center">
  -            Need <em>filename</em> or <em>url</em> parameters to
work
  -          </h3>
  -        }
  -      </xsp:logic>
  -    </body>
  -  </html>
  -</xsp:page>
  -
  +<?xml version="1.0"?>
  +<!-- Written by Ricardo Rocha <rrocha@plenix.org> -->
  +
  +<!-- A quick'n'dirty XML colorizer -->
  +
  +
  +<xsp:page
  +          language="java"
  +          xmlns:xsp="http://apache.org/xsp"
  +>
  +
  +  <xsp:structure>
  +   <xsp:include>java.net.*</xsp:include>
  +   <xsp:include>org.apache.cocoon.components.parser.XercesParser</xsp:include>
  +   <xsp:include>org.apache.cocoon.xml.XMLConsumer</xsp:include>
  +   <xsp:include>org.apache.cocoon.xml.DOMStreamer</xsp:include>
  +   <xsp:include>org.apache.cocoon.util.dom.DOMUtils</xsp:include>
  +   <xsp:include>javax.servlet.ServletContext</xsp:include>
  +   <xsp:include>javax.servlet.http.HttpServletRequest</xsp:include>
  +  </xsp:structure>
  +
  +  <xsp:logic><![CDATA[
  +    private static final String ATTR_NAME_COLOR = "darkblue";
  +    private static final String ATTR_VALUE_COLOR = "navy";
  +    private static final String COMMENT_COLOR = "gray";
  +    private static final String DELIMITER_COLOR = "blue";
  +    private static final String ELEMENT_COLOR = "navy";
  +    private static final String ENTITY_REF_COLOR = "navy";
  +    private static final String PI_COLOR = "darkred";
  +    private static final String TEXT_COLOR = "black";
  +    private static final String CUSTOM_ELEMENT_COLOR = "green";
  +    private static final String XSL_ELEMENT_COLOR = "purple";
  +    private static final String XSP_ELEMENT_COLOR = "green";
  +    private static final String XSP_TEXT_COLOR = "red";
  +
  +    private XercesParser xercesParser = new XercesParser();
  +
  +    protected void colorize(Node node, Document factory, org.xml.sax.ContentHandler contentHandler)
throws SAXException {
  +      Element element = factory.createElement("pre");
  +      DocumentFragment fragment = factory.createDocumentFragment();
  +      element.appendChild(doColorize(node, factory, 0, TEXT_COLOR));
  +      DOMStreamer ds = new DOMStreamer (contentHandler);
  +      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)
  +    {
  +      Element result = null;
  +      DocumentFragment fragment = factory.createDocumentFragment();
  +
  +      switch (node.getNodeType()) {
  +        case Node.CDATA_SECTION_NODE:
  +          result = factory.createElement("font");
  +          result.setAttribute("color", DELIMITER_COLOR);
  +          result.appendChild(factory.createTextNode("<![CDATA["));
  +          fragment.appendChild(result);
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", textColor);
  +          result.appendChild(factory.createTextNode(node.getNodeValue()));
  +          fragment.appendChild(result);
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", DELIMITER_COLOR);
  +          // I know the thing below is ugly, but man, nexted CDATA are a pain in the ass!
  +          result.appendChild(factory.createTextNode("]]]]>&gt;<![CDATA["));
  +          fragment.appendChild(result);
  +
  +          break;
  +        case Node.ELEMENT_NODE: {
  +          Element element = (Element) node;
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", DELIMITER_COLOR);
  +          result.appendChild(factory.createTextNode("<"));
  +          fragment.appendChild(result);
  +
  +          String tagColor = ELEMENT_COLOR;
  +          String tagName = element.getTagName();
  +
  +          if (tagName.startsWith("xsp:")) {
  +            tagColor = XSP_ELEMENT_COLOR;
  +          } else if (tagName.startsWith("xsl:")) {
  +            tagColor = XSL_ELEMENT_COLOR;
  +          } else if (tagName.indexOf(':') >= 0) {
  +            tagColor = CUSTOM_ELEMENT_COLOR;
  +          }
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", tagColor);
  +          result.appendChild(factory.createTextNode(tagName));
  +          fragment.appendChild(result);
  +
  +          NamedNodeMap attributes = element.getAttributes();
  +          int attributeCount = attributes.getLength();
  +
  +          for (int i = 0; i < attributeCount; i++) {
  +            Attr attribute = (Attr) attributes.item(i);
  +
  +            result = factory.createElement("font");
  +            result.setAttribute("color", ATTR_NAME_COLOR);
  +            result.appendChild(
  +              factory.createTextNode(" " + attribute.getName() + "=")
  +            );
  +            fragment.appendChild(result);
  +
  +            result = factory.createElement("font");
  +            result.setAttribute("color", ATTR_VALUE_COLOR);
  +            result.appendChild(
  +              factory.createTextNode("\"" + attribute.getValue() + "\"")
  +            );
  +            fragment.appendChild(result);
  +          }
  +
  +          NodeList nodeList = element.getChildNodes();
  +          int childCount = nodeList.getLength();
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", DELIMITER_COLOR);
  +          result.appendChild(
  +            factory.createTextNode((childCount == 0 ? "/" : "") + ">")
  +          );
  +          fragment.appendChild(result);
  +
  +          if (tagName.startsWith("xsp:")) {
  +            textColor = XSP_TEXT_COLOR;
  +          } else {
  +            textColor = TEXT_COLOR;
  +          }
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", textColor);
  +
  +          for (int i = 0; i < childCount; i++) {
  +            result.appendChild(
  +              doColorize(nodeList.item(i), factory, level + 1, textColor)
  +            );
  +          }
  +          fragment.appendChild(result);
  +
  +          if (childCount > 0) {
  +            result = factory.createElement("font");
  +            result.setAttribute("color", DELIMITER_COLOR);
  +            result.appendChild(factory.createTextNode("</"));
  +            fragment.appendChild(result);
  +
  +            result = factory.createElement("font");
  +            result.setAttribute("color", tagColor);
  +            result.appendChild(factory.createTextNode(tagName));
  +            fragment.appendChild(result);
  +
  +            result = factory.createElement("font");
  +            result.setAttribute("color", DELIMITER_COLOR);
  +            result.appendChild(factory.createTextNode(">"));
  +            fragment.appendChild(result);
  +          }
  +
  +          break;
  +        }
  +        case Node.DOCUMENT_NODE:
  +        case Node.DOCUMENT_FRAGMENT_NODE: {
  +          NodeList nodeList = node.getChildNodes();
  +          int childCount = nodeList.getLength();
  +
  +          for (int i = 0; i < childCount; i++) {
  +            fragment.appendChild(
  +              doColorize(nodeList.item(i), factory, level + 1, textColor)
  +            );
  +          }
  +
  +          break;
  +        }
  +        case Node.COMMENT_NODE:
  +          result = factory.createElement("font");
  +          result.setAttribute("color", COMMENT_COLOR);
  +
  +          result.appendChild(
  +            factory.createTextNode(
  +              "<!-- " + node.getNodeValue() + " -->\n"
  +            )
  +          );
  +
  +          fragment.appendChild(result);
  +
  +          break;
  +        case Node.PROCESSING_INSTRUCTION_NODE:
  +          ProcessingInstruction pi = (ProcessingInstruction) node;
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", DELIMITER_COLOR);
  +          result.appendChild(factory.createTextNode("<?"));
  +          fragment.appendChild(result);
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", PI_COLOR);
  +          result.appendChild(factory.createTextNode(pi.getTarget() + " " + pi.getData()));
  +          fragment.appendChild(result);
  +
  +          result = factory.createElement("font");
  +          result.setAttribute("color", DELIMITER_COLOR);
  +          result.appendChild(factory.createTextNode("?>\n"));
  +          fragment.appendChild(result);
  +
  +          break;
  +        case Node.ENTITY_REFERENCE_NODE:
  +          result = factory.createElement("font");
  +          result.setAttribute("color", ENTITY_REF_COLOR);
  +          result.appendChild(
  +            factory.createTextNode("<" + node.getNodeValue() + ";")
  +          );
  +          fragment.appendChild(result);
  +
  +          break;
  +        case Node.TEXT_NODE:
  +          fragment.appendChild(factory.createTextNode(node.getNodeValue()));
  +          break;
  +        default:
  +          break;
  +      }
  +
  +      return fragment;
  +    }
  +  ]]></xsp:logic>
  +
  +  <html>
  +    <xsp:logic>
  +      Document document = xercesParser.newDocument();
  +    </xsp:logic>
  +    <head>
  +      <title>Source Code</title>
  +      <link rel="stylesheet" type="text/css" href="style" title="Style"/>
  +    </head>
  +
  +    <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 {
  +            is = new InputSource (new FileReader (filepath));
  +            this.colorize(DOMUtils.DOMParse(is), 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>
  +
  +          InputSource is = null;
  +          try {
  +            is = new InputSource (resource.openStream());
  +            this.colorize(DOMUtils.DOMParse(is), document, this.contentHandler);
  +          } catch (FileNotFoundException fnfe) {
  +            throw new SAXException (fnfe);
  +          } catch (IOException ie) {
  +            throw new SAXException (ie);
  +          }
  +        } else {
  +          <h3 style="color:navy; text-align: center">
  +            Need <em>filename</em> or <em>url</em> parameters to
work
  +          </h3>
  +        }
  +      </xsp:logic>
  +    </body>
  +  </html>
  +</xsp:page>
  +
  
  
  

Mime
View raw message