[jdom-interest] Adding Locator support to SAXOutputter

Laurent Bihanic laurent.bihanic at atosorigin.com
Thu Apr 3 07:12:54 PST 2003


Hi,

While trying fix a problem in a class that feeds the output of SAXOutputter 
into another tool, I found it would be helpful if SAXOutputter could provide 
the information of which node was being processed at the time the error occurred.
To stay in the SAX "philosophy", the cleanest way was to use a Locator object 
(JDOMLocator) that exposes the node being processed.

Attached are the proposed JDOMLocator implementation and changes to SAXOutputter.

Laurent
-------------- next part --------------
Index: SAXOutputter.java
===================================================================
RCS file: /home/cvspublic/jdom/src/java/org/jdom/output/SAXOutputter.java,v
retrieving revision 1.26
diff -r1.26 SAXOutputter.java
3c3
<  $Id: SAXOutputter.java,v 1.26 2003/01/23 02:23:31 jhunter Exp $
---
>  $Id: SAXOutputter.java,v 1.26 2002/11/26 03:05:28 jhunter Exp $
65d64
< import org.xml.sax.Locator;
68d66
< import org.xml.sax.helpers.LocatorImpl;
106c104
<  * @version $Revision: 1.26 $, $Date: 2003/01/23 02:23:31 $
---
>  * @version $Revision: 1.26 $, $Date: 2002/11/26 03:05:28 $
111c109
<       "@(#) $RCSfile: SAXOutputter.java,v $ $Revision: 1.26 $ $Date: 2003/01/23 02:23:31 $ $Name:  $";
---
>       "@(#) $RCSfile: SAXOutputter.java,v $ $Revision: 1.26 $ $Date: 2002/11/26 03:05:28 $ $Name:  $";
196a195,200
>      * A SAX Locator that points at the JDOM node currently being
>      * outputted.
>      */
>     private JDOMLocator locator = null;
> 
>     /**
605a610,613
> 
>             // update locator
>             locator.setNode(obj);
> 
737c745
<         LocatorImpl locator = new LocatorImpl();
---
>         locator = new JDOMLocator();
831a840,842
>         // update locator
>         locator.setNode(element);
> 
995a1007,1009
> 
>             // update locator
>             locator.setNode(obj);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JDOMLocator.java
Type: text/x-java
Size: 3994 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20030403/bf47d0f5/JDOMLocator.bin


More information about the jdom-interest mailing list