Skip to content

Commit 7eb9311

Browse files
committed
[bugfix] Add missing base-uri accessors for in-memory DOM Text and Comment Nodes
1 parent 78d601b commit 7eb9311

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

exist-core/src/main/java/org/exist/dom/memtree/TextImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
import org.exist.xquery.Expression;
2525
import org.exist.xquery.value.Type;
2626
import org.w3c.dom.DOMException;
27+
import org.w3c.dom.Node;
2728
import org.w3c.dom.Text;
2829

30+
import javax.annotation.Nullable;
31+
2932

3033
public class TextImpl extends AbstractCharacterData implements Text {
3134

@@ -42,6 +45,15 @@ public int getItemType() {
4245
return Type.TEXT;
4346
}
4447

48+
@Override
49+
public @Nullable String getBaseURI() {
50+
@Nullable final Node parent = getParentNode();
51+
if (parent == null) {
52+
return null;
53+
}
54+
return parent.getBaseURI();
55+
}
56+
4557
@Override
4658
public Text splitText(final int offset) throws DOMException {
4759
return null;

exist-core/src/main/java/org/exist/dom/persistent/CommentImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
import org.w3c.dom.Comment;
5454
import org.w3c.dom.Node;
5555

56+
import javax.annotation.Nullable;
57+
5658
import static java.nio.charset.StandardCharsets.UTF_8;
5759

5860
public class CommentImpl extends AbstractCharacterData<CommentImpl> implements Comment {
@@ -86,6 +88,16 @@ public String toString() {
8688
return "<!-- " + cdata.toString() + " -->";
8789
}
8890

91+
@Override
92+
public @Nullable String getBaseURI() {
93+
@Nullable final Node parent = getParentNode();
94+
if (parent != null) {
95+
return parent.getBaseURI();
96+
} else {
97+
return null;
98+
}
99+
}
100+
89101
/**
90102
* Serializes a (persistent DOM) Comment to a byte array
91103
*

0 commit comments

Comments
 (0)