01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.lang.xml;
05
06 import java.io.Writer;
07
08 import net.sf.saxon.sxpath.IndependentContext;
09 import net.sourceforge.pmd.lang.DataFlowHandler;
10 import net.sourceforge.pmd.lang.LanguageVersionHandler;
11 import net.sourceforge.pmd.lang.Parser;
12 import net.sourceforge.pmd.lang.VisitorStarter;
13 import net.sourceforge.pmd.lang.XPathHandler;
14 import net.sourceforge.pmd.lang.ast.Node;
15 import net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator;
16 import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
17 import net.sourceforge.pmd.lang.xml.ast.DumpFacade;
18 import net.sourceforge.pmd.lang.xml.ast.XmlNode;
19 import net.sourceforge.pmd.lang.xml.rule.XmlRuleViolationFactory;
20
21 import org.jaxen.Navigator;
22
23 /**
24 * Implementation of LanguageVersionHandler for the XML.
25 */
26 public class XmlHandler implements LanguageVersionHandler {
27
28 public DataFlowHandler getDataFlowHandler() {
29 return DataFlowHandler.DUMMY;
30 }
31
32 public XPathHandler getXPathHandler() {
33 return new XPathHandler() {
34 public void initialize() {
35 }
36
37 public void initialize(IndependentContext context) {
38 }
39
40 public Navigator getNavigator() {
41 return new DocumentNavigator();
42 }
43 };
44 }
45
46 public RuleViolationFactory getRuleViolationFactory() {
47 return XmlRuleViolationFactory.INSTANCE;
48 }
49
50 public Parser getParser() {
51 return new XmlParser();
52 }
53
54 public VisitorStarter getDataFlowFacade() {
55 return VisitorStarter.DUMMY;
56 }
57
58 public VisitorStarter getSymbolFacade() {
59 return VisitorStarter.DUMMY;
60 }
61
62 public VisitorStarter getTypeResolutionFacade(ClassLoader classLoader) {
63 return VisitorStarter.DUMMY;
64 }
65
66 public VisitorStarter getDumpFacade(final Writer writer, final String prefix, final boolean recurse) {
67 return new VisitorStarter() {
68 public void start(Node rootNode) {
69 new DumpFacade().initializeWith(writer, prefix, recurse, (XmlNode) rootNode);
70 }
71 };
72 }
73 }
|