You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by di...@apache.org on 2001/02/07 13:45:55 UTC
cvs commit: xml-cocoon/webapp/docs/samples/slides view-source.xsp
dims 01/02/07 04:45:55
Modified: src/org/apache/cocoon/components/language/markup/xsp Tag:
xml-cocoon2 XSPUtil.java
webapp/docs/samples/slides Tag: xml-cocoon2 view-source.xsp
Log:
Fixed the XML Colorizer XSP (used in the slides sample.)
Revision Changes Path
No revision
No revision
1.1.2.3 +11 -1 xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPUtil.java
Index: XSPUtil.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/Attic/XSPUtil.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- XSPUtil.java 2001/01/02 20:33:31 1.1.2.2
+++ XSPUtil.java 2001/02/07 12:45:53 1.1.2.3
@@ -36,12 +36,13 @@
import org.apache.cocoon.xml.AbstractXMLConsumer;
import org.apache.cocoon.xml.IncludeXMLConsumer;
import org.apache.cocoon.xml.XMLConsumer;
+import org.apache.cocoon.xml.dom.DOMBuilder;
/**
* The XSP <code>Utility</code> object helper
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
* @author <a href="mailto:bloritsch@apache.org>Berin Loritsch</a>
- * @version $Revision: 1.1.2.2 $ $Date: 2001/01/02 20:33:31 $
+ * @version $Revision: 1.1.2.3 $ $Date: 2001/02/07 12:45:53 $
*/
public class XSPUtil {
public static String pathComponent(String filename) {
@@ -129,6 +130,15 @@
new IncludeXMLConsumer(parentContentHandler));
parser.parse(is);
}
+
+ public static org.w3c.dom.Document getDocument(InputSource input, Parser parser)
+ throws SAXException, IOException {
+ DOMBuilder builder = new DOMBuilder(parser);
+ parser.setContentHandler(builder);
+ parser.setLexicalHandler(builder);
+ parser.parse(input);
+ return builder.getDocument();
+ }
public static String encodeMarkup(String string) {
char[] array = string.toCharArray();
No revision
No revision
1.1.2.4 +5 -7 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.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- view-source.xsp 2000/09/08 18:49:42 1.1.2.3
+++ view-source.xsp 2001/02/07 12:45:54 1.1.2.4
@@ -1,5 +1,6 @@
<?xml version="1.0"?>
<!-- Written by Ricardo Rocha <rr...@plenix.org> -->
+<!-- Fixed for C2 by Davanum Srinivas <di...@yahoo.com> -->
<!-- A quick'n'dirty XML colorizer -->
@@ -11,10 +12,9 @@
<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.dom.DOMStreamer</xsp:include>
- <xsp:include>org.apache.cocoon.util.DOMUtils</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:structure>
@@ -33,8 +33,6 @@
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();
@@ -282,7 +280,7 @@
<html>
<xsp:logic>
- Document document = xercesParser.newDocument();
+ Document document = parser.newDocument();
</xsp:logic>
<head>
<title>Source Code</title>
@@ -309,7 +307,7 @@
InputSource is = null;
try {
is = new InputSource (new FileReader (filepath));
- this.colorize(DOMUtils.DOMParse(is), document, this.contentHandler);
+ this.colorize(XSPUtil.getDocument(is,parser), document, this.contentHandler);
} catch (FileNotFoundException fnfe) {
throw new SAXException (fnfe);
} catch (IOException ie) {
@@ -331,7 +329,7 @@
InputSource is = null;
try {
is = new InputSource (resource.openStream());
- this.colorize(DOMUtils.DOMParse(is), document, this.contentHandler);
+ this.colorize(XSPUtil.getDocument(is,parser), document, this.contentHandler);
} catch (FileNotFoundException fnfe) {
throw new SAXException (fnfe);
} catch (IOException ie) {