1
1
/*
2
- * Copyright 2008-2014 James Murty (www.jamesmurty.com)
2
+ * Copyright 2008-2017 James Murty (www.jamesmurty.com)
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -101,18 +101,22 @@ protected XMLBuilder(Node myNode, Node parentNode) {
101
101
* default namespace URI for document, ignored if null or empty.
102
102
* @param enableExternalEntities
103
103
* enable external entities; beware of XML External Entity (XXE) injection.
104
+ * @param isNamespaceAware
105
+ * enable or disable namespace awareness in the underlying
106
+ * {@link DocumentBuilderFactory}
104
107
* @return
105
108
* a builder node that can be used to add more nodes to the XML document.
106
109
*
107
110
* @throws FactoryConfigurationError
108
111
* @throws ParserConfigurationException
109
112
*/
110
113
public static XMLBuilder create (String name , String namespaceURI ,
111
- boolean enableExternalEntities )
114
+ boolean enableExternalEntities , boolean isNamespaceAware )
112
115
throws ParserConfigurationException , FactoryConfigurationError
113
116
{
114
117
return new XMLBuilder (
115
- createDocumentImpl (name , namespaceURI , enableExternalEntities ));
118
+ createDocumentImpl (
119
+ name , namespaceURI , enableExternalEntities , isNamespaceAware ));
116
120
}
117
121
118
122
/**
@@ -124,16 +128,20 @@ public static XMLBuilder create(String name, String namespaceURI,
124
128
* the name of the document's root element.
125
129
* @param enableExternalEntities
126
130
* enable external entities; beware of XML External Entity (XXE) injection.
131
+ * @param isNamespaceAware
132
+ * enable or disable namespace awareness in the underlying
133
+ * {@link DocumentBuilderFactory}
127
134
* @return
128
135
* a builder node that can be used to add more nodes to the XML document.
129
136
*
130
137
* @throws FactoryConfigurationError
131
138
* @throws ParserConfigurationException
132
139
*/
133
- public static XMLBuilder create (String name , boolean enableExternalEntities )
140
+ public static XMLBuilder create (String name , boolean enableExternalEntities ,
141
+ boolean isNamespaceAware )
134
142
throws ParserConfigurationException , FactoryConfigurationError
135
143
{
136
- return create (name , null , enableExternalEntities );
144
+ return create (name , null , enableExternalEntities , isNamespaceAware );
137
145
}
138
146
139
147
/**
@@ -146,6 +154,7 @@ public static XMLBuilder create(String name, boolean enableExternalEntities)
146
154
* the name of the document's root element.
147
155
* @param namespaceURI
148
156
* default namespace URI for document, ignored if null or empty.
157
+
149
158
* @return
150
159
* a builder node that can be used to add more nodes to the XML document.
151
160
*
@@ -155,7 +164,7 @@ public static XMLBuilder create(String name, boolean enableExternalEntities)
155
164
public static XMLBuilder create (String name , String namespaceURI )
156
165
throws ParserConfigurationException , FactoryConfigurationError
157
166
{
158
- return create (name , namespaceURI , false );
167
+ return create (name , namespaceURI , false , true );
159
168
}
160
169
161
170
/**
@@ -186,6 +195,9 @@ public static XMLBuilder create(String name)
186
195
* an XML document input source that will be parsed into a DOM.
187
196
* @param enableExternalEntities
188
197
* enable external entities; beware of XML External Entity (XXE) injection.
198
+ * @param isNamespaceAware
199
+ * enable or disable namespace awareness in the underlying
200
+ * {@link DocumentBuilderFactory}
189
201
* @return
190
202
* a builder node that can be used to add more nodes to the XML document.
191
203
* @throws ParserConfigurationException
@@ -196,11 +208,13 @@ public static XMLBuilder create(String name)
196
208
* @throws SAXException
197
209
*/
198
210
public static XMLBuilder parse (
199
- InputSource inputSource , boolean enableExternalEntities )
211
+ InputSource inputSource , boolean enableExternalEntities ,
212
+ boolean isNamespaceAware )
200
213
throws ParserConfigurationException , SAXException , IOException
201
214
{
202
215
return new XMLBuilder (
203
- parseDocumentImpl (inputSource , enableExternalEntities ));
216
+ parseDocumentImpl (
217
+ inputSource , enableExternalEntities , isNamespaceAware ));
204
218
}
205
219
206
220
/**
@@ -212,6 +226,9 @@ public static XMLBuilder parse(
212
226
* an XML document string that will be parsed into a DOM.
213
227
* @param enableExternalEntities
214
228
* enable external entities; beware of XML External Entity (XXE) injection.
229
+ * @param isNamespaceAware
230
+ * enable or disable namespace awareness in the underlying
231
+ * {@link DocumentBuilderFactory}
215
232
* @return
216
233
* a builder node that can be used to add more nodes to the XML document.
217
234
*
@@ -222,12 +239,14 @@ public static XMLBuilder parse(
222
239
* @throws SAXException
223
240
*/
224
241
public static XMLBuilder parse (
225
- String xmlString , boolean enableExternalEntities )
242
+ String xmlString , boolean enableExternalEntities ,
243
+ boolean isNamespaceAware )
226
244
throws ParserConfigurationException , SAXException , IOException
227
245
{
228
246
return XMLBuilder .parse (
229
247
new InputSource (new StringReader (xmlString )),
230
- enableExternalEntities );
248
+ enableExternalEntities ,
249
+ isNamespaceAware );
231
250
}
232
251
233
252
/**
@@ -239,6 +258,9 @@ public static XMLBuilder parse(
239
258
* an XML document file that will be parsed into a DOM.
240
259
* @param enableExternalEntities
241
260
* enable external entities; beware of XML External Entity (XXE) injection.
261
+ * @param isNamespaceAware
262
+ * enable or disable namespace awareness in the underlying
263
+ * {@link DocumentBuilderFactory}
242
264
* @return
243
265
* a builder node that can be used to add more nodes to the XML document.
244
266
*
@@ -248,11 +270,14 @@ public static XMLBuilder parse(
248
270
* @throws IOException
249
271
* @throws SAXException
250
272
*/
251
- public static XMLBuilder parse (File xmlFile , boolean enableExternalEntities )
273
+ public static XMLBuilder parse (File xmlFile , boolean enableExternalEntities ,
274
+ boolean isNamespaceAware )
252
275
throws ParserConfigurationException , SAXException , IOException
253
276
{
254
277
return XMLBuilder .parse (
255
- new InputSource (new FileReader (xmlFile )), enableExternalEntities );
278
+ new InputSource (new FileReader (xmlFile )),
279
+ enableExternalEntities ,
280
+ isNamespaceAware );
256
281
}
257
282
258
283
/**
@@ -274,7 +299,7 @@ public static XMLBuilder parse(File xmlFile, boolean enableExternalEntities)
274
299
public static XMLBuilder parse (InputSource inputSource )
275
300
throws ParserConfigurationException , SAXException , IOException
276
301
{
277
- return XMLBuilder .parse (inputSource , false );
302
+ return XMLBuilder .parse (inputSource , false , true );
278
303
}
279
304
280
305
/**
@@ -296,7 +321,7 @@ public static XMLBuilder parse(InputSource inputSource)
296
321
public static XMLBuilder parse (String xmlString )
297
322
throws ParserConfigurationException , SAXException , IOException
298
323
{
299
- return XMLBuilder .parse (xmlString , false );
324
+ return XMLBuilder .parse (xmlString , false , true );
300
325
}
301
326
302
327
/**
@@ -318,7 +343,7 @@ public static XMLBuilder parse(String xmlString)
318
343
public static XMLBuilder parse (File xmlFile )
319
344
throws ParserConfigurationException , SAXException , IOException
320
345
{
321
- return XMLBuilder .parse (xmlFile , false );
346
+ return XMLBuilder .parse (xmlFile , false , true );
322
347
}
323
348
324
349
@ Override
0 commit comments