public void serialize(Node node, boolean callDocumentEvents) throws SAXException { if(callDocumentEvents) contentHandler.startDocument(); Node top = node; while (node != null) { startNode(node); Node nextNode = node.getFirstChild(); while (nextNode == null) { endNode(node); if (top != null && top.equals(node)) break; nextNode = node.getNextSibling(); if (nextNode == null) { node = node.getParentNode(); if (node == null || (top != null && top.equals(node))) { endNode(node); nextNode = null; break; } } } node = nextNode; } if(callDocumentEvents) contentHandler.endDocument(); }
public void serialize(Node node) throws SAXException { serialize(node, false); }
	public void serialize(Node node, boolean callDocumentEvents) throws SAXException {        if(callDocumentEvents)            contentHandler.startDocument();		Node top = node;		while (node != null) {			startNode(node);			Node nextNode = node.getFirstChild();			while (nextNode == null) {				endNode(node);				if (top != null && top.equals(node))					break;				nextNode = node.getNextSibling();				if (nextNode == null) {					node = node.getParentNode();					if (node == null || (top != null && top.equals(node))) {						endNode(node);						nextNode = null;						break;					}				}			}			node = nextNode;		}        if(callDocumentEvents)            contentHandler.endDocument();	}