54
54
import javax .xml .XMLConstants ;
55
55
import javax .xml .stream .XMLStreamConstants ;
56
56
import javax .xml .stream .XMLStreamException ;
57
+ import javax .annotation .Nonnull ;
57
58
import java .io .DataInputStream ;
58
59
import java .io .DataOutputStream ;
59
60
import java .io .IOException ;
@@ -795,22 +796,17 @@ public void setAttributes(final short attribNum) {
795
796
}
796
797
797
798
@ Override
799
+ @ Nonnull
798
800
public String getAttribute (final String name ) {
799
801
final Attr attr = findAttribute (name );
800
802
return attr != null ? attr .getValue () : "" ;
801
803
}
802
804
803
805
@ Override
806
+ @ Nonnull
804
807
public String getAttributeNS (final String namespaceURI , final String localName ) {
805
808
final Attr attr = findAttribute (new QName (localName , namespaceURI ));
806
- return attr != null ? attr .getValue () : XMLConstants .NULL_NS_URI ;
807
- //XXX: if not present must return null
808
- }
809
-
810
- @ Deprecated //move as soon as getAttributeNS null issue resolved
811
- public String _getAttributeNS (final String namespaceURI , final String localName ) {
812
- final Attr attr = findAttribute (new QName (localName , namespaceURI ));
813
- return attr != null ? attr .getValue () : null ;
809
+ return attr != null ? attr .getValue () : "" ;
814
810
}
815
811
816
812
@ Override
@@ -951,6 +947,7 @@ public boolean hasChildNodes() {
951
947
}
952
948
953
949
@ Override
950
+ @ Nonnull
954
951
public NodeList getChildNodes () {
955
952
final int childNodesLen = children - attributes ;
956
953
final org .exist .dom .NodeListImpl childList = new org .exist .dom .NodeListImpl (childNodesLen );
@@ -1008,6 +1005,7 @@ private void getChildren(final boolean includeAttributes, final org.exist.dom.No
1008
1005
}
1009
1006
1010
1007
@ Override
1008
+ @ Nonnull
1011
1009
public NodeList getElementsByTagName (final String name ) {
1012
1010
if (name != null && name .equals (QName .WILDCARD )) {
1013
1011
return getElementsByTagName (new QName .WildcardLocalPartQName (XMLConstants .DEFAULT_NS_PREFIX ));
@@ -1021,6 +1019,7 @@ public NodeList getElementsByTagName(final String name) {
1021
1019
}
1022
1020
1023
1021
@ Override
1022
+ @ Nonnull
1024
1023
public NodeList getElementsByTagNameNS (final String namespaceURI , final String localName ) {
1025
1024
final boolean wildcardNS = namespaceURI != null && namespaceURI .equals (QName .WILDCARD );
1026
1025
final boolean wildcardLocalPart = localName != null && localName .equals (QName .WILDCARD );
@@ -1977,9 +1976,9 @@ public String getBaseURI() {
1977
1976
private XmldbURI calculateBaseURI () {
1978
1977
XmldbURI baseURI = null ;
1979
1978
1980
- final String nodeBaseURI = _getAttributeNS (Namespaces .XML_NS , "base" );
1979
+ final Node nodeBaseURI = getAttributeNodeNS (Namespaces .XML_NS , "base" );
1981
1980
if (nodeBaseURI != null ) {
1982
- baseURI = XmldbURI .create (nodeBaseURI , false );
1981
+ baseURI = XmldbURI .create (nodeBaseURI . getNodeValue () , false );
1983
1982
if (baseURI .isAbsolute ()) {
1984
1983
return baseURI ;
1985
1984
}
@@ -1991,7 +1990,7 @@ private XmldbURI calculateBaseURI() {
1991
1990
baseURI = ((ElementImpl ) parent ).calculateBaseURI ();
1992
1991
} else {
1993
1992
XmldbURI parentsBaseURI = ((ElementImpl ) parent ).calculateBaseURI ();
1994
- if (nodeBaseURI .isEmpty ()) {
1993
+ if (nodeBaseURI .getNodeValue (). isEmpty ()) {
1995
1994
baseURI = parentsBaseURI ;
1996
1995
} else {
1997
1996
if (parentsBaseURI .toString ().endsWith ("/" ) || !parentsBaseURI .toString ().contains ("/" )){
0 commit comments