You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by tm...@apache.org on 2001/08/01 21:23:22 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/trax TransformerImpl.java DOM2SAX.java

tmiller     01/08/01 12:23:22

  Modified:    java/src/org/apache/xalan/xsltc/trax TransformerImpl.java
                        DOM2SAX.java
  Log:
  add support for DOMResult handling
  
  Revision  Changes    Path
  1.10      +26 -7     xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java
  
  Index: TransformerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/TransformerImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TransformerImpl.java	2001/07/23 08:47:56	1.9
  +++ TransformerImpl.java	2001/08/01 19:23:22	1.10
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TransformerImpl.java,v 1.9 2001/07/23 08:47:56 morten Exp $
  + * @(#)$Id: TransformerImpl.java,v 1.10 2001/08/01 19:23:22 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -88,6 +88,7 @@
   
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.parsers.ParserConfigurationException;
   import javax.xml.transform.*;
   import javax.xml.transform.sax.*;
   import javax.xml.transform.dom.*;
  @@ -144,18 +145,27 @@
       public void transform(Source source, Result result)
   	throws TransformerException {
   
  -	if (_translet == null)
  +	if (_translet == null) {
   	    throw new TransformerException(TRANSLET_ERR_MSG);
  +	}
   
   	_handler = getOutputHandler(result);
  -	if (_handler == null)
  +	if (_handler == null) { 
   	    throw new TransformerException(HANDLER_ERR_MSG);
  +	}
   
  -	if (_uriResolver != null)
  +	if (_uriResolver != null) {
   	    _translet.setDOMCache(this);
  -	
  +	}
  +
   	// Run the transformation
   	transform(source, _handler, _encoding);
  +
  +	// If a DOMResult, then we must set the DOM Tree so it can
  +	// be retrieved later 
  +	if (result instanceof DOMResult) {
  +	    ((DOMResult)result).setNode(((SAX2DOM)_handler).getDOM());
  +	}
       }
   
       /**
  @@ -193,6 +203,10 @@
   		else if (writer != null)
   		    return (new DefaultSAXOutputHandler(writer, _encoding));
   	    }
  +	    // Handle DOMResult output handler
  +	    else if (result instanceof DOMResult) {
  +		return (new SAX2DOM());
  +	    }
   
   	    // Common, final handling of all input sources, only used if the
   	    // other contents of the Result object could not be used
  @@ -213,6 +227,11 @@
   	catch (java.net.UnknownServiceException e) {
   	    throw new TransformerException(e);
   	}
  +	// If we cannot create a SAX2DOM adapter
  +	catch (ParserConfigurationException e) {
  +	    throw new TransformerException(
  +		"SAX2DOM adapter could not be created, " + e.getMessage());
  +	}
   	// If we cannot create the file specified by the SystemId
   	catch (java.io.IOException e) {
   	    throw new TransformerException(e);
  @@ -250,8 +269,8 @@
   		final DOMSource   domsrc = (DOMSource)source;
   		final Document    tree = (Document)domsrc.getNode();
   		final DOM2SAX     dom2sax = new DOM2SAX(tree);
  -		final InputSource input = SAXSource.sourceToInputSource(source);
  -		final String      systemId = domsrc.getSystemId();
  +		final InputSource input = null; 
  +		final String      systemId = null; 
   		dtdMonitor.handleDTD(dom2sax);
   		dom2sax.setContentHandler(inputHandler);
   		dom2sax.parse(input);
  
  
  
  1.3       +3 -1      xml-xalan/java/src/org/apache/xalan/xsltc/trax/DOM2SAX.java
  
  Index: DOM2SAX.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/trax/DOM2SAX.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DOM2SAX.java	2001/07/20 20:07:44	1.2
  +++ DOM2SAX.java	2001/08/01 19:23:22	1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DOM2SAX.java,v 1.2 2001/07/20 20:07:44 tmiller Exp $
  + * @(#)$Id: DOM2SAX.java,v 1.3 2001/08/01 19:23:22 tmiller Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -107,6 +107,8 @@
   	SAXNotRecognizedException, SAXNotSupportedException 
       {
       }
  +
  +    // Input is not used.
       public void parse(InputSource input) throws IOException, SAXException {
   	Node currNode = _dom; 
   	while (currNode != null) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org