01: package org.dom4j.io;
02:
03: import org.dom4j.DocumentFactory;
04: import org.dom4j.ElementHandler;
05: import org.dom4j.LElement;
06: import org.xml.sax.Attributes;
07: import org.xml.sax.Locator;
08: import org.xml.sax.SAXException;
09:
10: public class LNSAXContentHandler extends SAXContentHandler {
11: private Locator locator;
12:
13: public LNSAXContentHandler() {
14: super ();
15: }
16:
17: /**
18: * @param documentFactory
19: */
20: public LNSAXContentHandler(DocumentFactory documentFactory) {
21: super (documentFactory);
22: }
23:
24: /**
25: * @param documentFactory
26: * @param elementHandler
27: */
28: public LNSAXContentHandler(DocumentFactory documentFactory,
29: ElementHandler elementHandler) {
30: super (documentFactory, elementHandler);
31: }
32:
33: /* (non-Javadoc)
34: * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
35: */
36: public void startElement(String namespaceURI, String localName,
37: String qualifiedName, Attributes attributes)
38: throws SAXException {
39: int lineNumber = locator.getLineNumber();
40: super .startElement(namespaceURI, localName, qualifiedName,
41: attributes);
42: LElement element = (LElement) getElementStack().getCurrent();
43: element.setLineNumber(lineNumber);
44: }
45:
46: /* (non-Javadoc)
47: * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
48: */
49: public void setDocumentLocator(Locator documentLocator) {
50: super.setDocumentLocator(documentLocator);
51: this.locator = documentLocator;
52: }
53: }
|