[jdom-commits] CVS Update: jdom/src/java/org/jdom/input

nobody nobody at chimbo.servlets.com
Tue Jun 17 13:49:43 PDT 2003


****************************************
Date:   Tue Jun 17, 2003 @14:49:43 MDT
Author: 

Update of /home/cvs/jdom/src/java/org/jdom/input
In directory chimbo:/tmp/cvs-serv22663/input

Modified Files:
SAXHandler.java
Log Message:
Changing SAXHandler.setAlternateRoot() to SAXHandler.pushElement()
which solves the same problem but in a more general way. Laurent
had the idea (see below), and it's a darn good one!

-jh-

> SAXHandler:
> atRoot
>
> I see JDOMResult.FragmentHandler uses this. That's an odd property
> to expose. Could this be done another way? Laurent?


Sure, this could be removed if SAXHandler provided a protected
pushElement() method. As JDOMResult may receive a node list and not
a document, it needs to add a dummy root element to the being-built
document before the parse begins. To do that, I simply pasted some
code from startElement.

For example, in SAXHandler:

protected void pushElement(Element element) {
if (atRoot) {
document.setRootElement(element);
atRoot = false;
} else {
getCurrentElement().addContent(element);
}
currentElement = element;
}

Then JDOMResult.FragmentHandler constructor could be changed to:
public FragmentHandler(JDOMFactory factory) {
super(factory);

// Add a dummy root element to the being-built document as XSL
// transformation can output node lists instead of well-formed
// documents.
this.pushElement(dummyRoot);
}

Laurent


===================================================================
File: no file SAXHandler.java		Status: Needs Checkout

   Working revision:	1.59	Tue Jun 17 20:49:43 2003
   Repository revision:	1.59	/home/cvs/jdom/src/java/org/jdom/input/SAXHandler.java,v

   Existing Tags:
	jdom_1_0_b9              	(revision: 1.50)
	jdom_1_0_b8              	(revision: 1.39)
	jdom_prefilter           	(revision: 1.27)
	jdom_1_0_b7              	(revision: 1.18)




More information about the jdom-commits mailing list