File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
exist-core/src/main/java/org/exist/dom/persistent Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1300,12 +1300,19 @@ public Text createTextNode(final String data) {
13001300 */
13011301 @ Override
13021302 public Element getDocumentElement () {
1303- final NodeList cl = getChildNodes ();
1304- for (int i = 0 ; i < cl .getLength (); i ++) {
1305- if (cl .item (i ).getNodeType () == Node .ELEMENT_NODE ) {
1306- return (Element ) cl .item (i );
1303+ try (final DBBroker broker = pool .getBroker ()) {
1304+ final NodeProxy childNodeProxy = new NodeProxy (getExpression (), this , NodeId .DOCUMENT_NODE );
1305+ for (int i = 0 ; i < children ; i ++) {
1306+ childNodeProxy .setInternalAddress (childAddress [i ]);
1307+ final Node child = broker .objectWith (childNodeProxy );
1308+ if (child .getNodeType () == Node .ELEMENT_NODE ) {
1309+ return (Element ) child ;
1310+ }
13071311 }
1312+ } catch (final EXistException e ) {
1313+ LOG .warn ("Exception while retrieving document element: {}" , e .getMessage (), e );
13081314 }
1315+
13091316 return null ;
13101317 }
13111318
You can’t perform that action at this time.
0 commit comments