java.net.* org.w3c.dom.* org.apache.cocoon.xml.dom.DOMStreamer org.apache.cocoon.xml.dom.DOMBuilder org.apache.cocoon.components.parser.Parser org.apache.cocoon.components.url.URLFactory >= 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); } 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( "\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("\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; } ]]> Source Code String filename = request.getParameter("filename"); if (filename != null) {

filename

Parser newParser = null; URLFactory factory = null; try { newParser = (Parser) this.manager.lookup(Parser.ROLE); factory = (URLFactory) this.manager.lookup(URLFactory.ROLE); 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 (SAXException e){ getLogger().debug("SAXException in colorize", e); throw e; } catch (org.w3c.dom.DOMException e){ getLogger().debug("DOMException in colorize", e); throw e; } catch (Exception e) { getLogger().error("Could not include page", e); } finally { this.manager.release((Component) factory); this.manager.release((Component) newParser); } } else {

Need filename or url parameters to work

}