1 package net.sf.tomp.xml.include;
2
3 import net.sf.tomp.xml.type.Type;
4 import net.sf.tomp.xml.type.VariantImpl;
5
6 import org.apache.commons.logging.Log;
7 import org.apache.commons.logging.LogFactory;
8 import org.xml.sax.SAXException;
9 import org.xml.sax.XMLReader;
10
11 /***
12 * DOCUMENT ME!
13 *
14 * @author $author$
15 * @version $Revision$
16 */
17 public class AdaptiveXIncludeFilter extends AdaptiveFilterImpl {
18 private Log log = LogFactory.getLog(AdaptiveXIncludeFilter.class);
19
20 /*** DOCUMENT ME! */
21 protected XIncludeFilter xif;
22
23 private final String XINCLUDE_NAMESPACE = "http://tomp.sf.net/ns/axi/1.0";
24
25 /***
26 * Creates a new AdaptiveXIncludeFilter object.
27 */
28 public AdaptiveXIncludeFilter() {
29 super();
30 xif = getXIncludeFilter();
31 xif.setParent(parent);
32 parent = xif;
33 log.debug("\n&&&& " + this + "<init>: xif=" + xif);
34 }
35
36 /***
37 * Construct an XML filter with the specified parent.
38 *
39 * @param p DOCUMENT ME!
40 * @see #setParent
41 * @see #getParent
42 */
43 public AdaptiveXIncludeFilter(XMLReader p) {
44 super(p);
45 xif = getXIncludeFilter();
46 xif.setParent(parent);
47 parent = xif;
48 log.debug("\n&&&& " + this + "<init>: xif=" + xif);
49
50
51
52 }
53
54 /***
55 * DOCUMENT ME!
56 *
57 * @param p DOCUMENT ME!
58 */
59 public void setParent(XMLReader p) {
60 xif.setParent(typeDetectorFilter);
61 this.parent = xif;
62
63
64
65 if (typeDetectorFilter != null) {
66 typeDetectorFilter.setParent(p);
67 }
68 }
69
70
71
72
73
74
75
76 public XIncludeFilter getXIncludeFilter() {
77 final AdaptiveXIncludeFilter axi = this;
78
79 XIncludeFilter xif = new XIncludeFilter() {
80 public String getXIncludeNamespace() {
81 return XINCLUDE_NAMESPACE;
82 }
83
84 public XMLReader getXMLReader(String variant) throws SAXException {
85
86
87 XMLReader parser = super.getXMLReader(variant);
88
89
90 AdaptiveFilterImpl adaptive = new AdaptiveXIncludeFilter(parser);
91
92
93 log.debug("+++++ returning " + adaptive
94 + " from getXMLReader() in " + this);
95
96
97 adaptive.setVariant(new VariantImpl(variant));
98 adaptive.setTypeDatabase(getTypeDatabase());
99
100 Type s = getSourceType();
101 Type t = getSourceTypeForCurrentContext();
102
103
104 adaptive.setTargetType(t);
105
106
107 return adaptive;
108 }
109 };
110
111 log.debug("--- returning " + xif + " from getXIncludeFilter() in "
112 + this);
113
114 return xif;
115 }
116
117 /***
118 * @return Returns the xINCLUDE_NAMESPACE.
119 */
120 public String getXIncludeNamespace() {
121 return XINCLUDE_NAMESPACE;
122 }
123 }
124
125
126
127
128
129
130
131
132
133
134