1 package org.objectweb.celtix.tools.utils; 2 3 import org.w3c.dom.Element ; 4 5 import org.xml.sax.SAXNotRecognizedException ; 6 import org.xml.sax.SAXNotSupportedException ; 7 8 import com.sun.org.apache.xerces.internal.parsers.DOMParser; 9 import com.sun.org.apache.xerces.internal.util.SymbolTable; 10 import com.sun.org.apache.xerces.internal.xni.Augmentations; 11 import com.sun.org.apache.xerces.internal.xni.NamespaceContext; 12 import com.sun.org.apache.xerces.internal.xni.QName; 13 import com.sun.org.apache.xerces.internal.xni.XMLAttributes; 14 import com.sun.org.apache.xerces.internal.xni.XMLLocator; 15 import com.sun.org.apache.xerces.internal.xni.XNIException; 16 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; 17 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; 18 19 import org.objectweb.celtix.tools.common.ToolException; 20 import org.objectweb.celtix.tools.common.WSDLConstants; 21 22 public class LineNumDOMParser extends DOMParser { 23 private XMLLocator locator; 24 25 public LineNumDOMParser() throws SAXNotSupportedException , SAXNotRecognizedException { 26 super(); 27 28 setFeature(DEFER_NODE_EXPANSION, false); 29 30 } 31 32 public LineNumDOMParser(XMLParserConfiguration arg0) throws ToolException { 33 super(arg0); 34 try { 35 setFeature(DEFER_NODE_EXPANSION, false); 36 } catch (SAXNotSupportedException e) { 37 throw new ToolException(e); 38 } catch (SAXNotRecognizedException e) { 39 throw new ToolException(e); 40 } 41 } 42 43 public LineNumDOMParser(SymbolTable st) { 44 super(st); 45 } 46 47 public LineNumDOMParser(SymbolTable st, XMLGrammarPool xp) { 48 super(st, xp); 49 } 50 51 public void startElement(QName qn, XMLAttributes xmlAtr, Augmentations aug) throws XNIException { 52 Element element; 53 64 super.startElement(qn, xmlAtr, aug); 65 try { 66 element = (Element )getProperty(CURRENT_ELEMENT_NODE); 67 element.setUserData(WSDLConstants.NODE_LOCATION, new ElementLocator(locator.getLineNumber(), 68 locator.getColumnNumber()), 69 null); 70 71 } catch (ClassCastException e) { 72 } catch (SAXNotRecognizedException e) { 74 } catch (SAXNotSupportedException e) { 76 } 78 79 } 80 81 public void startDocument(XMLLocator xmlLoc, String str, NamespaceContext nsCxt, Augmentations aug) 82 throws XNIException { 83 locator = xmlLoc; 84 super.startDocument(xmlLoc, str, nsCxt, aug); 85 86 } 87 88 } 89 | Popular Tags |