@@ -89,6 +89,53 @@ protected XMLBuilder(Node myNode, Node parentNode) {
8989 super (myNode , parentNode );
9090 }
9191
92+ /**
93+ * Construct a builder for new XML document with a default namespace.
94+ * The document will be created with the given root element, and the builder
95+ * returned by this method will serve as the starting-point for any further
96+ * document additions.
97+ *
98+ * @param name
99+ * the name of the document's root element.
100+ * @param namespaceURI
101+ * default namespace URI for document, ignored if null or empty.
102+ * @param enableExternalEntities
103+ * enable external entities; beware of XML External Entity (XXE) injection.
104+ * @return
105+ * a builder node that can be used to add more nodes to the XML document.
106+ *
107+ * @throws FactoryConfigurationError
108+ * @throws ParserConfigurationException
109+ */
110+ public static XMLBuilder create (String name , String namespaceURI ,
111+ boolean enableExternalEntities )
112+ throws ParserConfigurationException , FactoryConfigurationError
113+ {
114+ return new XMLBuilder (
115+ createDocumentImpl (name , namespaceURI , enableExternalEntities ));
116+ }
117+
118+ /**
119+ * Construct a builder for new XML document. The document will be created
120+ * with the given root element, and the builder returned by this method
121+ * will serve as the starting-point for any further document additions.
122+ *
123+ * @param name
124+ * the name of the document's root element.
125+ * @param enableExternalEntities
126+ * enable external entities; beware of XML External Entity (XXE) injection.
127+ * @return
128+ * a builder node that can be used to add more nodes to the XML document.
129+ *
130+ * @throws FactoryConfigurationError
131+ * @throws ParserConfigurationException
132+ */
133+ public static XMLBuilder create (String name , boolean enableExternalEntities )
134+ throws ParserConfigurationException , FactoryConfigurationError
135+ {
136+ return create (name , null , enableExternalEntities );
137+ }
138+
92139 /**
93140 * Construct a builder for new XML document with a default namespace.
94141 * The document will be created with the given root element, and the builder
@@ -108,7 +155,7 @@ protected XMLBuilder(Node myNode, Node parentNode) {
108155 public static XMLBuilder create (String name , String namespaceURI )
109156 throws ParserConfigurationException , FactoryConfigurationError
110157 {
111- return new XMLBuilder ( createDocumentImpl ( name , namespaceURI ) );
158+ return create ( name , namespaceURI , false );
112159 }
113160
114161 /**
@@ -130,6 +177,84 @@ public static XMLBuilder create(String name)
130177 return create (name , null );
131178 }
132179
180+ /**
181+ * Construct a builder from an existing XML document. The provided XML
182+ * document will be parsed and an XMLBuilder object referencing the
183+ * document's root element will be returned.
184+ *
185+ * @param inputSource
186+ * an XML document input source that will be parsed into a DOM.
187+ * @param enableExternalEntities
188+ * enable external entities; beware of XML External Entity (XXE) injection.
189+ * @return
190+ * a builder node that can be used to add more nodes to the XML document.
191+ * @throws ParserConfigurationException
192+ *
193+ * @throws FactoryConfigurationError
194+ * @throws ParserConfigurationException
195+ * @throws IOException
196+ * @throws SAXException
197+ */
198+ public static XMLBuilder parse (
199+ InputSource inputSource , boolean enableExternalEntities )
200+ throws ParserConfigurationException , SAXException , IOException
201+ {
202+ return new XMLBuilder (
203+ parseDocumentImpl (inputSource , enableExternalEntities ));
204+ }
205+
206+ /**
207+ * Construct a builder from an existing XML document string.
208+ * The provided XML document will be parsed and an XMLBuilder
209+ * object referencing the document's root element will be returned.
210+ *
211+ * @param xmlString
212+ * an XML document string that will be parsed into a DOM.
213+ * @param enableExternalEntities
214+ * enable external entities; beware of XML External Entity (XXE) injection.
215+ * @return
216+ * a builder node that can be used to add more nodes to the XML document.
217+ *
218+ * @throws ParserConfigurationException
219+ * @throws FactoryConfigurationError
220+ * @throws ParserConfigurationException
221+ * @throws IOException
222+ * @throws SAXException
223+ */
224+ public static XMLBuilder parse (
225+ String xmlString , boolean enableExternalEntities )
226+ throws ParserConfigurationException , SAXException , IOException
227+ {
228+ return XMLBuilder .parse (
229+ new InputSource (new StringReader (xmlString )),
230+ enableExternalEntities );
231+ }
232+
233+ /**
234+ * Construct a builder from an existing XML document file.
235+ * The provided XML document will be parsed and an XMLBuilder
236+ * object referencing the document's root element will be returned.
237+ *
238+ * @param xmlFile
239+ * an XML document file that will be parsed into a DOM.
240+ * @param enableExternalEntities
241+ * enable external entities; beware of XML External Entity (XXE) injection.
242+ * @return
243+ * a builder node that can be used to add more nodes to the XML document.
244+ *
245+ * @throws ParserConfigurationException
246+ * @throws FactoryConfigurationError
247+ * @throws ParserConfigurationException
248+ * @throws IOException
249+ * @throws SAXException
250+ */
251+ public static XMLBuilder parse (File xmlFile , boolean enableExternalEntities )
252+ throws ParserConfigurationException , SAXException , IOException
253+ {
254+ return XMLBuilder .parse (
255+ new InputSource (new FileReader (xmlFile )), enableExternalEntities );
256+ }
257+
133258 /**
134259 * Construct a builder from an existing XML document. The provided XML
135260 * document will be parsed and an XMLBuilder object referencing the
@@ -149,7 +274,7 @@ public static XMLBuilder create(String name)
149274 public static XMLBuilder parse (InputSource inputSource )
150275 throws ParserConfigurationException , SAXException , IOException
151276 {
152- return new XMLBuilder ( parseDocumentImpl ( inputSource ) );
277+ return XMLBuilder . parse ( inputSource , false );
153278 }
154279
155280 /**
@@ -171,7 +296,7 @@ public static XMLBuilder parse(InputSource inputSource)
171296 public static XMLBuilder parse (String xmlString )
172297 throws ParserConfigurationException , SAXException , IOException
173298 {
174- return XMLBuilder .parse (new InputSource ( new StringReader ( xmlString )) );
299+ return XMLBuilder .parse (xmlString , false );
175300 }
176301
177302 /**
@@ -193,7 +318,7 @@ public static XMLBuilder parse(String xmlString)
193318 public static XMLBuilder parse (File xmlFile )
194319 throws ParserConfigurationException , SAXException , IOException
195320 {
196- return XMLBuilder .parse (new InputSource ( new FileReader ( xmlFile )) );
321+ return XMLBuilder .parse (xmlFile , false );
197322 }
198323
199324 @ Override
0 commit comments