[From nobody Fri Aug 6 17:06:23 2004 Return-Path: <frank.nestel@coi.de> Delivered-To: jhunter@collab.net Received: (qmail 18210 invoked by uid 0); 31 May 2001 07:23:17 -0000 Received: from mail.acm.org (199.222.69.4) by laswell.sp.collab.net with SMTP; 31 May 2001 07:23:17 -0000 Received: from dorothy.denveronline.net (dorothy.denveronline.net [206.168.141.2]) by mail.acm.org (8.9.3/8.9.3) with ESMTP id DAA75334 for <jhunter@acm.org>; Thu, 31 May 2001 03:23:15 -0400 Received: from nmemonix.com (www.nmemonix.com [195.74.128.200]) by dorothy.denveronline.net (8.9.3/8.9.3) with SMTP id BAA03457 for <jhunter@jdom.org>; Thu, 31 May 2001 01:23:11 -0600 (MDT) Received: (qmail 27029 invoked by uid 514); 31 May 2001 07:02:13 -0000 Delivered-To: jhunter@cvs.jdom.org Received: (qmail 27026 invoked from network); 31 May 2001 07:02:13 -0000 Received: from su00777.ina.de (HELO ina.de) (159.51.6.53) by www.nmemonix.com with SMTP; 31 May 2001 07:02:13 -0000 Received: from ina-de0135.ina.de (pc11322.ina.de [159.51.6.55]) by ina.de (8.9.3+Sun/8.9.1) with SMTP id JAA02142 for <jhunter@cvs.jdom.org>; Thu, 31 May 2001 09:22:27 +0200 (MET DST) Received: FROM coi01.coi.com BY ina-de0135.ina.de ; Thu May 31 09:22:26 2001 +0200 Received: by coi01.coi.com with Internet Mail Service (5.5.2653.19) id <LR4HQ4AP>; Thu, 31 May 2001 09:22:45 +0200 Message-ID: <571B91EF5DD1D211A04900A0C9EAD2C8010FA72B@coi01.coi.com> From: "Nestel, Frank" <frank.nestel@coi.de> To: "'jhunter@cvs.jdom.org'" <jhunter@cvs.jdom.org> Subject: JDOM new class Date: Thu, 31 May 2001 09:22:41 +0200 Return-Receipt-To: "Nestel, Frank" <frank.nestel@coi.de> MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C0E9A2.7A85B290" X-Mozilla-Status2: 00800000 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C0E9A2.7A85B290 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello, excuse me for being overly direct. I know you are busy, but I am busy too and I do not wan't to go the whole procedure of subscribing a newslist posting my proposal and unsubscribe again, though I think the following might be useful to JDOM. Attached find the source for an org.jdom.outputter.XMLReaderAdapter which allows easier passing around JDOM generated SAX events into other stages of processing (e.g. stylesheet processor), for example: Document doc2 =3D .... SAXSource source =3D new SAXSource(); org.jdom.output.XMLReaderAdapter so=20 =3D new org.jdom.output.XMLReaderAdapter(); so.setDocument(doc2); source.setInputSource( ... ); // SAXON needs an InputSource = object ... source.setXMLReader(so); Result outResult =3D ... transformer.transform(source, outResult); Since the XMLReaderAdapter is subclasses from SAXOutputter I had to change some of SAXOutputters members from private to protected. Though we allready use XMLReaderAdapter here, there are some fine points about properties and features which should probably be improved. The source code has been developed in JDK1.1 fashion, if you use it you have to change the collections packages. BTW stealing your time allready, another API I'd expected to see was a mathod with a signature like java.util.Map Element.getAttributes() i.e. this would allow to pass the while Attribute Mapping. Anyway, thank you very much for the good work, best regards -- Dr. Frank Sven Nestel Principal Software Engineer COI GmbH Erlanger Stra=DFe 62, D-91074 Herzogenaurach Phone +49 (0) 9132 82 4611=20 http://www.coi.de, mailto:Frank.Nestel@coi.de COI - Solutions for Documents ------_=_NextPart_000_01C0E9A2.7A85B290 Content-Type: application/octet-stream; name="XMLReaderAdapter.java" Content-Disposition: attachment; filename="XMLReaderAdapter.java" package org.jdom.output; import org.jdom.*; import org.xml.sax.*; public class XMLReaderAdapter extends SAXOutputter implements XMLReader { protected Document myDoc = null; public void setDocument(Document doc) { myDoc = doc; } public Document getDocument() { return myDoc; } public void parse(InputSource in) throws SAXException { parse(); } public void parse(String in) throws SAXException { parse(); } protected void parse() throws SAXException { if ( myDoc == null ) throw new SAXException("Missing JDOM Document."); try { output(myDoc); } catch ( JDOMException je ) { throw new SAXException(je); } } // // XXX Dummy implementations of the XMLReader API public boolean getFeature(String name) { return true; // XXX } public void setFeature(String name, boolean val) { // XXX } public Object getProperty(String name) { return ""; // XXX } public void setProperty(String name, Object val) { // XXX } public EntityResolver getEntityResolver() { return entityResolver; } public ContentHandler getContentHandler() { return contentHandler; } public DTDHandler getDTDHandler() { return dtdHandler; } public ErrorHandler getErrorHandler() { return errorHandler; } } ------_=_NextPart_000_01C0E9A2.7A85B290 Content-Type: application/octet-stream; name="SAXOutputter.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="SAXOutputter.java" /*-- =0A= =0A= $Id: SAXOutputter.java,v 1.7 2001/04/27 18:21:21 jhunter Exp $=0A= =0A= Copyright (C) 2000 Brett McLaughlin & Jason Hunter.=0A= All rights reserved.=0A= =0A= Redistribution and use in source and binary forms, with or without=0A= modification, are permitted provided that the following conditions=0A= are met:=0A= =0A= 1. Redistributions of source code must retain the above copyright=0A= notice, this list of conditions, and the following disclaimer.=0A= =0A= 2. Redistributions in binary form must reproduce the above = copyright=0A= notice, this list of conditions, and the disclaimer that follows = =0A= these conditions in the documentation and/or other materials =0A= provided with the distribution.=0A= =0A= 3. The name "JDOM" must not be used to endorse or promote products=0A= derived from this software without prior written permission. = For=0A= written permission, please contact license@jdom.org.=0A= =0A= 4. Products derived from this software may not be called "JDOM", = nor=0A= may "JDOM" appear in their name, without prior written = permission=0A= from the JDOM Project Management (pm@jdom.org).=0A= =0A= In addition, we request (but do not require) that you include in the = =0A= end-user documentation provided with the redistribution and/or in the = =0A= software itself an acknowledgement equivalent to the following:=0A= "This product includes software developed by the=0A= JDOM Project (http://www.jdom.org/)."=0A= Alternatively, the acknowledgment may be graphical using the logos =0A= available at http://www.jdom.org/images/logos.=0A= =0A= THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED=0A= WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES=0A= OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE=0A= DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT=0A= CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=0A= SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0A= LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF=0A= USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND=0A= ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,=0A= OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT=0A= OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF=0A= SUCH DAMAGE.=0A= =0A= This software consists of voluntary contributions made by many =0A= individuals on behalf of the JDOM Project and was originally =0A= created by Brett McLaughlin <brett@jdom.org> and =0A= Jason Hunter <jhunter@jdom.org>. For more information on the =0A= JDOM Project, please see <http://www.jdom.org/>.=0A= =0A= */=0A= =0A= package org.jdom.output;=0A= =0A= import java.io.IOException;=0A= import com.sun.java.util.collections.Iterator;=0A= import com.sun.java.util.collections.List;=0A= =0A= import org.xml.sax.ContentHandler;=0A= import org.xml.sax.ErrorHandler;=0A= import org.xml.sax.DTDHandler;=0A= import org.xml.sax.EntityResolver;=0A= import org.xml.sax.SAXException;=0A= import org.xml.sax.Locator;=0A= import org.xml.sax.helpers.LocatorImpl;=0A= import org.xml.sax.helpers.AttributesImpl;=0A= =0A= import org.jdom.Document;=0A= import org.jdom.DocType;=0A= import org.jdom.JDOMException;=0A= import org.jdom.ProcessingInstruction;=0A= import org.jdom.Element;=0A= import org.jdom.Namespace;=0A= import org.jdom.Attribute;=0A= import org.jdom.CDATA;=0A= =0A= /**=0A= * <p>=0A= * <code>SAXOutputter</code> takes a JDOM tree and fires SAX2 = events.=0A= * </p>=0A= *=0A= * Most <code>ContentHandler</code> callbacks are supported. Both=0A= * <code>ignorableWhitespace</code> and <code>skippedEntity</code> = have=0A= * not been implemented. The <code>setDocumentLocator</code> callback = has=0A= * been implemented, but the locator object always returns -1 for=0A= * <code>getColumnNumber</code> and <code>getLineNumber</code>.=0A= * </p>=0A= *=0A= * The <code>EntityResolver</code> callback <code>resolveEntity</code> = has=0A= * been implemented for DTDs.=0A= * </p>=0A= *=0A= * At this time, it is not possible to access notations and unparsed = entity=0A= * references in a DTD from a JDOM tree. Therefore, = <code>DTDHandler</code>=0A= * callbacks have not been implemented yet.=0A= * </p>=0A= *=0A= * The <code>ErrorHandler</code> callbacks have not been implemented, = since=0A= * these are supposed to be invoked when the document is parsed. = However, the=0A= * document has already been parsed in order to create the JDOM = tree.=0A= * </p>=0A= *=0A= * @author Brett McLaughlin=0A= * @author Jason Hunter=0A= * @author Fred Trimble=0A= * @version 1.0=0A= */=0A= public class SAXOutputter {=0A= =0A= private static final String CVS_ID =3D =0A= "@(#) $RCSfile: SAXOutputter.java,v $ $Revision: 1.7 $ $Date: = 2001/04/27 18:21:21 $ $Name: $";=0A= =0A= /** registered <code>ContentHandler</code> */=0A= protected ContentHandler contentHandler;=0A= =0A= /** registered <code>ErrorHandler</code> */=0A= protected ErrorHandler errorHandler;=0A= =0A= /** registered <code>DTDHandler</code> */=0A= protected DTDHandler dtdHandler;=0A= =0A= /** registered <code>EntityResolver</code> */=0A= protected EntityResolver entityResolver;=0A= =0A= /**=0A= * <p>=0A= * This will create a <code>SAXOutputter</code> with the=0A= * specified <code>ContentHandler</code>.=0A= * </p>=0A= *=0A= * @param contentHandler contains <code>ContentHandler</code> = callback methods=0A= */=0A= public SAXOutputter() {=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will create a <code>SAXOutputter</code> with the=0A= * specified <code>ContentHandler</code>.=0A= * </p>=0A= *=0A= * @param contentHandler contains <code>ContentHandler</code> = callback methods=0A= */=0A= public SAXOutputter(ContentHandler contentHandler) {=0A= this.contentHandler =3D contentHandler;=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will create a <code>SAXOutputter</code> with the=0A= * specified SAX2 handlers. At this time, only = <code>ContentHandler</code>=0A= * and <code>EntityResolver</code> are supported.=0A= * </p>=0A= *=0A= * @param contentHandler contains <code>ContentHandler</code> = callback methods=0A= * @param errorHandler contains <code>ErrorHandler</code> callback = methods=0A= * @param dtdHandler contains <code>DTDHandler</code> callback = methods=0A= * @param entityResolver contains <code>EntityResolver</code> = callback methods=0A= */=0A= public SAXOutputter(ContentHandler contentHandler,=0A= ErrorHandler errorHandler,=0A= DTDHandler dtdHandler,=0A= EntityResolver entityResolver) {=0A= this.contentHandler =3D contentHandler;=0A= this.errorHandler =3D errorHandler;=0A= this.dtdHandler =3D dtdHandler;=0A= this.entityResolver =3D entityResolver;=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will set the <code>ContentHandler</code>.=0A= * </p>=0A= *=0A= * @param contentHandler contains <code>ContentHandler</code> = callback methods.=0A= */=0A= public void setContentHandler(ContentHandler contentHandler) {=0A= this.contentHandler =3D contentHandler;=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will set the <code>ErrorHandler</code>.=0A= * </p>=0A= *=0A= * @param errorHandler contains <code>ErrorHandler</code> callback = methods.=0A= */=0A= public void setErrorHandler(ErrorHandler errorHandler) {=0A= this.errorHandler =3D errorHandler;=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will set the <code>DTDHandler</code>.=0A= * </p>=0A= *=0A= * @param dtdHandler contains <code>DTDHandler</code> callback = methods.=0A= */=0A= public void setDTDHandler(DTDHandler dtdHandler) {=0A= this.dtdHandler =3D dtdHandler;=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will set the <code>EntityResolver</code>.=0A= * </p>=0A= *=0A= * @param entityResolver contains EntityResolver callback = methods.=0A= */=0A= public void setEntityResolver(EntityResolver entityResolver) {=0A= this.entityResolver =3D entityResolver;=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will output the <code>JDOM Document</code>, firing off = the=0A= * SAX events that have been registered.=0A= * </p>=0A= *=0A= * @param document <code>JDOM Document</code> to output.=0A= */=0A= public void output(Document document) throws JDOMException {=0A= if (document =3D=3D null) {=0A= return;=0A= }=0A= =0A= // contentHandler.setDocumentLocator()=0A= documentLocator(document);=0A= =0A= // contentHandler.startDocument()=0A= startDocument();=0A= =0A= // entityResolver.resolveEntity()=0A= entityResolver(document);=0A= =0A= // JDOM cannot read unparsed entities and notations in DTD = (yet)=0A= // dtdHandler(document);=0A= =0A= // Handle root element, as well as any root level=0A= // processing instructions and CDATA sections=0A= Iterator i =3D document.getMixedContent().iterator();=0A= while (i.hasNext()) {=0A= Object obj =3D i.next();=0A= if (obj instanceof Element) {=0A= // process root element and its mixed content=0A= element(document.getRootElement(), new = NamespaceStack());=0A= }=0A= else if (obj instanceof ProcessingInstruction) {=0A= // contentHandler.processingInstruction()=0A= processingInstruction((ProcessingInstruction) obj);=0A= }=0A= else if (obj instanceof CDATA) {=0A= // contentHandler.characters()=0A= characters(((CDATA) obj).getText());=0A= }=0A= }=0A= =0A= // contentHandler.endDocument()=0A= endDocument();=0A= }=0A= =0A= /**=0A= * <p>=0A= * This enables an application to resolve external entities.=0A= * </p>=0A= *=0A= * @param document JDOM <code>Document</code>.=0A= */=0A= private void entityResolver(Document document) throws JDOMException = {=0A= if (entityResolver !=3D null) {=0A= DocType docType =3D document.getDocType();=0A= String publicID =3D null;=0A= String systemID =3D null;=0A= if (docType !=3D null) {=0A= publicID =3D docType.getPublicID();=0A= systemID =3D docType.getSystemID();=0A= }=0A= =0A= if ((publicID !=3D null) || (systemID !=3D null)) {=0A= try {=0A= entityResolver.resolveEntity(publicID, systemID);=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= catch (IOException ioe) {=0A= throw new JDOMException("IOException", ioe);=0A= }=0A= }=0A= }=0A= }=0A= =0A= // Not implemented yet, since a JDOM Document does not=0A= // have access to the unparsed entities and notations=0A= // defined in a DTD (yet)=0A= // private void dtdHandler(Document document) {=0A= // }=0A= =0A= /**=0A= * <p>=0A= * This method tells you the line of the XML file being parsed.=0A= * For an in-memory document, it's meaningless. The location=0A= * is only valid for the current parsing lifecycle, but=0A= * the document has already been parsed. Therefore, it returns=0A= * -1 for both line and column numbers.=0A= * </p>=0A= *=0A= * @param document JDOM <code>Document</code>.=0A= */=0A= private void documentLocator(Document document) {=0A= LocatorImpl locator =3D new LocatorImpl();=0A= String publicID =3D null;=0A= String systemID =3D null;=0A= DocType docType =3D document.getDocType();=0A= if (docType !=3D null) {=0A= publicID =3D docType.getPublicID();=0A= systemID =3D docType.getSystemID();=0A= }=0A= =0A= locator.setPublicId(publicID);=0A= locator.setSystemId(systemID);=0A= locator.setLineNumber(-1);=0A= locator.setColumnNumber(-1);=0A= =0A= contentHandler.setDocumentLocator((Locator) locator);=0A= }=0A= =0A= /**=0A= * <p>=0A= * This method is always the second method of all callbacks in=0A= * all handlers to be invoked (setDocumentLocator is always = first).=0A= * </p>=0A= */=0A= private void startDocument() throws JDOMException {=0A= try {=0A= contentHandler.startDocument();=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * Always the last method of all callbacks in all handlers=0A= * to be invoked.=0A= * </p>=0A= */=0A= private void endDocument() throws JDOMException {=0A= try {=0A= contentHandler.endDocument();=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will invoke the = <code>ContentHandler.processingInstruction</code>=0A= * callback when a processing instruction is encountered.=0A= * </p>=0A= *=0A= * @param pi <code>ProcessingInstruction</code> containing target = and data.=0A= */=0A= private void processingInstruction(ProcessingInstruction pi) throws = JDOMException {=0A= if (pi !=3D null) {=0A= String target =3D pi.getTarget();=0A= String data =3D pi.getData();=0A= try {=0A= contentHandler.processingInstruction(target, data);=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will recursively invoke all of the callbacks for a = particular element.=0A= * </p>=0A= *=0A= * @param element <code>Element</code> used in callbacks.=0A= * @param namespaces <code>List</code> stack of Namespaces in = scope.=0A= */=0A= private void element(Element element, NamespaceStack namespaces) = throws JDOMException {=0A= // used to check endPrefixMapping=0A= int previouslyDeclaredNamespaces =3D namespaces.size();=0A= =0A= // contentHandler.startPrefixMapping()=0A= startPrefixMapping(element, namespaces);=0A= =0A= // contentHandler.startElement()=0A= startElement(element);=0A= =0A= // handle mixed content in the element=0A= elementContent(element, namespaces);=0A= =0A= // contentHandler.endElement()=0A= endElement(element);=0A= =0A= // contentHandler.endPrefixMapping()=0A= endPrefixMapping(namespaces, previouslyDeclaredNamespaces);=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will invoke the = <code>ContentHandler.startPrefixMapping</code> callback=0A= * when a new namespace is encountered in the = <code>Document</code>.=0A= * </p>=0A= *=0A= * @param element <code>Element</code> used in callbacks.=0A= * @param namespaces <code>List</code> stack of Namespaces in = scope.=0A= */=0A= private void startPrefixMapping(Element element, NamespaceStack = namespaces) throws JDOMException {=0A= Namespace ns =3D element.getNamespace();=0A= if (ns !=3D Namespace.NO_NAMESPACE && ns !=3D = Namespace.XML_NAMESPACE) {=0A= String prefix =3D ns.getPrefix();=0A= String uri =3D namespaces.getURI(prefix);=0A= if (!ns.getURI().equals(uri)) {=0A= namespaces.push(ns);=0A= try {=0A= contentHandler.startPrefixMapping(prefix, = ns.getURI());=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will invoke the <code>endPrefixMapping</code> callback in = the=0A= * <code>ContentHandler</code> when a namespace is goes out of = scope=0A= * in the <code>Document</code>.=0A= * </p>=0A= *=0A= * @param namespaces <code>List</code> stack of Namespaces in = scope.=0A= * @param previouslyDeclaredNamespaces number of previously declared = namespaces=0A= */=0A= private void endPrefixMapping(NamespaceStack namespaces, int = previouslyDeclaredNamespaces) throws JDOMException {=0A= while (namespaces.size() > previouslyDeclaredNamespaces) {=0A= String prefix =3D namespaces.pop();=0A= try {=0A= contentHandler.endPrefixMapping(prefix);=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will invoke the <code>startElement</code> callback=0A= * in the <code>ContentHandler</code>.=0A= * </p>=0A= *=0A= * @param element <code>Element</code> used in callbacks.=0A= */=0A= private void startElement(Element element) throws JDOMException {=0A= String namespaceURI =3D element.getNamespaceURI();=0A= String localName =3D element.getName();=0A= String rawName =3D element.getQualifiedName();=0A= AttributesImpl atts =3D new AttributesImpl();=0A= List attributes =3D element.getAttributes();=0A= Iterator i =3D attributes.iterator();=0A= while (i.hasNext()) {=0A= Attribute a =3D (Attribute) i.next();=0A= atts.addAttribute(a.getNamespaceURI(),=0A= a.getName(),=0A= a.getQualifiedName(),=0A= "CDATA",=0A= a.getValue());=0A= }=0A= =0A= try {=0A= contentHandler.startElement(namespaceURI, localName, rawName, = atts);=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will invoke the <code>endElement</code> callback=0A= * in the <code>ContentHandler</code>.=0A= * </p>=0A= *=0A= * @param element <code>Element</code> used in callbacks.=0A= */=0A= private void endElement(Element element) throws JDOMException {=0A= String namespaceURI =3D element.getNamespaceURI();=0A= String localName =3D element.getName();=0A= String rawName =3D element.getQualifiedName();=0A= =0A= try {=0A= contentHandler.endElement(namespaceURI, localName, = rawName);=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will invoke the callbacks for the content of an element.=0A= * </p>=0A= *=0A= * @param element <code>Element</code> used in callbacks.=0A= * @param namespaces <code>List</code> stack of Namespaces in = scope.=0A= */=0A= private void elementContent(Element element, NamespaceStack = namespaces) throws JDOMException {=0A= List mixedContent =3D element.getMixedContent();=0A= =0A= boolean empty =3D mixedContent.size() =3D=3D 0;=0A= boolean stringOnly =3D=0A= !empty &&=0A= mixedContent.size() =3D=3D 1 &&=0A= mixedContent.get(0) instanceof String;=0A= =0A= if (stringOnly) {=0A= // contentHandler.characters()=0A= characters(element.getText());=0A= }=0A= else {=0A= Object content =3D null;=0A= for (int i =3D 0, size =3D mixedContent.size(); i < size; i++) = {=0A= content =3D mixedContent.get(i);=0A= if (content instanceof Element) {=0A= element((Element) content, namespaces);=0A= }=0A= else if (content instanceof String) {=0A= // contentHandler.characters()=0A= characters((String) content);=0A= }=0A= else if (content instanceof CDATA) {=0A= // contentHandler.characters()=0A= characters(((CDATA) content).getText());=0A= }=0A= else if (content instanceof ProcessingInstruction) {=0A= // contentHandler.processingInstruction()=0A= processingInstruction((ProcessingInstruction) = content);=0A= }=0A= }=0A= }=0A= }=0A= =0A= /**=0A= * <p>=0A= * This will be called for each chunk of character data = encountered.=0A= * </p>=0A= *=0A= * @param elementText all text in an element, including = whitespace.=0A= */=0A= private void characters(String elementText) throws JDOMException = {=0A= char[] c =3D elementText.toCharArray();=0A= try {=0A= contentHandler.characters(c, 0, c.length);=0A= }=0A= catch (SAXException se) {=0A= throw new JDOMException("SAXException", se);=0A= }=0A= }=0A= }=0A= ------_=_NextPart_000_01C0E9A2.7A85B290-- ]