68
68
import javax .xml .xpath .XPathConstants ;
69
69
import javax .xml .xpath .XPathExpressionException ;
70
70
import javax .xml .xpath .XPathFactory ;
71
+ import net .sf .saxon .trans .SymbolicName ;
71
72
import net .sf .saxon .xpath .XPathFactoryImpl ;
72
73
import org .w3c .dom .Document ;
73
74
import org .w3c .dom .Node ;
@@ -126,7 +127,7 @@ public final class XMLDocument implements XML {
126
127
*/
127
128
public XMLDocument (final String text ) {
128
129
this (
129
- new DomParser (XMLDocument . configuredDFactory () , text ).document (),
130
+ new DomParser (FACTORY , text ).document (),
130
131
new XPathContext (),
131
132
false
132
133
);
@@ -152,7 +153,7 @@ public XMLDocument(final String text) {
152
153
*/
153
154
public XMLDocument (final byte [] data ) {
154
155
this (
155
- new DomParser (XMLDocument . configuredDFactory () , data ).document (),
156
+ new DomParser (FACTORY , data ).document (),
156
157
new XPathContext (),
157
158
false
158
159
);
@@ -202,8 +203,8 @@ public XMLDocument(final Source source) {
202
203
* @throws FileNotFoundException In case of I/O problems
203
204
*/
204
205
public XMLDocument (final File file ) throws FileNotFoundException {
205
- this (new TextResource (file ).toString ());
206
- // this(new DomParser(XMLDocument.configuredDFactory() , file).document());
206
+ // this(new TextResource(file).toString());
207
+ this (new DomParser (FACTORY , file ).document ());
207
208
}
208
209
209
210
/**
@@ -322,7 +323,8 @@ public Node node() {
322
323
final Node casted = this .cache ;
323
324
final Node answer ;
324
325
if (casted instanceof Document ) {
325
- answer = casted .cloneNode (true );
326
+ answer = casted ;
327
+ // answer = casted.cloneNode(true);
326
328
} else {
327
329
answer = XMLDocument .createImportedNode (casted );
328
330
}
@@ -478,7 +480,7 @@ public Collection<SAXParseException> validate(final Schema schema) {
478
480
* @return A cloned node imported in a dedicated document.
479
481
*/
480
482
private static Node createImportedNode (final Node node ) {
481
- final DocumentBuilderFactory factory = XMLDocument . configuredDFactory () ;
483
+ final DocumentBuilderFactory factory = FACTORY ;
482
484
final DocumentBuilder builder ;
483
485
try {
484
486
builder = factory .newDocumentBuilder ();
@@ -599,6 +601,8 @@ private static Node transform(final Source source) {
599
601
return result .getNode ();
600
602
}
601
603
604
+ private static final DocumentBuilderFactory FACTORY = XMLDocument .configuredDFactory ();
605
+
602
606
/**
603
607
* Create new {@link DocumentBuilderFactory} and configure it.
604
608
* @return Configured factory
0 commit comments