Project

Profile

Help

XdmNode.getBaseURI NPE on attribute

Added by Anonymous almost 15 years ago

Legacy ID: #7784327 Legacy Poster: David Lee (daldei)

Calling XdmNode.getBaseURI with an Attribute node causes an NPE in Saxon 9.1 The core crash is calling new URI( null ) In XdmNode.java > Blockquote public URI getBaseURI() { try { return new URI(getUnderlyingNode().getBaseURI()); } catch (URISyntaxException e) { throw new IllegalStateException("baseURI"); } } > Blockquote


Replies (2)

RE: XdmNode.getBaseURI NPE on attribute - Added by Anonymous almost 15 years ago

Legacy ID: #7788545 Legacy Poster: Michael Kay (mhkay)

I haven't succeeded in reproducing the problem. You didn't give much information about the context; but I suspect you are working with a tree in which the base URI has not been initialized. You are presumably expecting null to be returned in this situation.

RE: XdmNode.getBaseURI NPE on attribute - Added by Anonymous almost 15 years ago

Legacy ID: #7788555 Legacy Poster: David Lee (daldei)

Yes and yes. I can generate a test case if you want it, but yes this was a case of a synthesized document (xquery constructed) without a base URI, and I was expecting a null instead of an NPE. I suggest public URI getBaseURI() { try { String base = getUnderlyingNode().getBaseURI(); return base == null?null : new URI(base); } catch (URISyntaxException e) { throw new IllegalStateException("baseURI"); } }

    (1-2/2)

    Please register to reply