KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > tools > utils > LineNumDOMParser


1 package org.objectweb.celtix.tools.utils;
2
3 import org.w3c.dom.Element JavaDoc;
4
5 import org.xml.sax.SAXNotRecognizedException JavaDoc;
6 import org.xml.sax.SAXNotSupportedException JavaDoc;
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 JavaDoc, SAXNotRecognizedException JavaDoc {
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 JavaDoc e) {
37             throw new ToolException(e);
38         } catch (SAXNotRecognizedException JavaDoc 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 JavaDoc element;
53         /*
54          * String ns = qn.uri; if (ns != null &&
55          * (ns.equals(Constants.NS_URI_XSD_2001) ||
56          * ns.equals(Constants.NS_URI_XSD_1999) || ns
57          * .equals(Constants.NS_URI_XSD_2000))) { int numatts =
58          * xmlAtr.getLength(); System.out.println("---arg1--- " + xmlAtr); for
59          * (int i = 0; i < numatts; i++) { String nonNormalizedValue =
60          * xmlAtr.getNonNormalizedValue(i);
61          * System.out.println("---nonNormalizedValue--- " + nonNormalizedValue);
62          * xmlAtr.setValue(i, nonNormalizedValue); } }
63          */

64         super.startElement(qn, xmlAtr, aug);
65         try {
66             element = (Element JavaDoc)getProperty(CURRENT_ELEMENT_NODE);
67             element.setUserData(WSDLConstants.NODE_LOCATION, new ElementLocator(locator.getLineNumber(),
68                                                                                 locator.getColumnNumber()),
69                                 null);
70
71         } catch (ClassCastException JavaDoc e) {
72             // System.out.println(e);
73
} catch (SAXNotRecognizedException JavaDoc e) {
74             // System.out.println(e);
75
} catch (SAXNotSupportedException JavaDoc e) {
76             // System.out.println(e);
77
}
78
79     }
80
81     public void startDocument(XMLLocator xmlLoc, String JavaDoc 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