cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ba...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xinclude XIncludeProcessor.java
Date Tue, 09 May 2000 05:48:46 GMT
balld       00/05/08 22:48:44

  Modified:    src/org/apache/cocoon/processor/xinclude
                        XIncludeProcessor.java
  Log:
  playing around with xptr support
  
  Revision  Changes    Path
  1.2       +10 -5     xml-cocoon/src/org/apache/cocoon/processor/xinclude/XIncludeProcessor.java
  
  Index: XIncludeProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xinclude/XIncludeProcessor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XIncludeProcessor.java	2000/05/09 05:16:08	1.1
  +++ XIncludeProcessor.java	2000/05/09 05:48:44	1.2
  @@ -43,7 +43,7 @@
    * from my XInclude filter for cocoon2.
    *
    * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2000/05/09 05:16:08 $ $Author: balld $
  + * @version CVS $Revision: 1.2 $ $Date: 2000/05/09 05:48:44 $ $Author: balld $
    */
   public class XIncludeProcessor extends AbstractActor implements Processor, Status {
   
  @@ -159,7 +159,7 @@
   		if (uri != null && uri.equals(processor.XINCLUDE_NAMESPACE_URI) && name.equals(processor.XINCLUDE_INCLUDE_ELEMENT))
{
   			String href = element.getAttribute(processor.XINCLUDE_INCLUDE_ELEMENT_HREF_ATTRIBUTE);
   			String parse = element.getAttribute(processor.XINCLUDE_INCLUDE_ELEMENT_PARSE_ATTRIBUTE);
  -			processXIncludeElement(document, element, href, parse);
  +			processXIncludeElement(element, href, parse);
   		}
   		NodeList child_nodes = element.getElementsByTagName("*");
   		int length = child_nodes.getLength();
  @@ -186,7 +186,7 @@
   		current_xmlbase_uri = (URL)xmlbase_stack.pop();
   	}
   
  -	void processXIncludeElement(Document document, Element element, String href, String parse)
throws Exception {
  +	void processXIncludeElement(Element element, String href, String parse) throws Exception
{
   		if (debug) { System.err.println("Processing XInclude element: href="+href+", parse="+parse);
}
   		String suffix;
   		int index = href.indexOf('#');
  @@ -247,15 +247,20 @@
   			} else {
   				throw new Exception("Unknown object type: "+object);
   			}
  -			Document included_document = parser.parse(input);
  +			Document included_document = null;
  +			try {
  +				included_document = parser.parse(input,false);
  +			} catch (Exception e) {}
   			if (suffix.startsWith("xptr(") && suffix.endsWith(")")) {
  -				String xpath = suffix.substring(6,suffix.length()-1);
  +				String xpath = suffix.substring(5,suffix.length()-1);
   				if (debug) { System.err.println("XPath is "+xpath); }
   				NodeList list = XPathAPI.selectNodeList(included_document,xpath);
   				int length = list.getLength();
  +				if (debug) { System.err.println("Found "+length+" nodes"); }
   				for (int i=0; i<length; i++) {
   					result_fragment.appendChild(document.importNode(list.item(i),true));
   				}
  +				result_fragment.appendChild(document.importNode(included_document.getDocumentElement(),true));
   			} else {
   				result_fragment.appendChild(document.importNode(included_document.getDocumentElement(),true));
   			}
  
  
  

Mime
View raw message