Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Processing XML with Java question

 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
As I am trying to compile and run examples in "Processing XML with Java" as part of preperation, I am stuck at DOMSpider program in book. Can anyone please explain on why it is occuring? Thanks.

The example am working on is DOMSpider shownhere

When run against site given there i.e. "http://www.rddl.org/" am getting following exception.

java.lang.NullPointerException
at org.apache.crimson.tree.ElementNode2.getAttributeNodeNS(ElementNode2.
java:432)
at org.apache.crimson.tree.ElementNode2.getAttributeNS(ElementNode2.java
:409)
at DOMSpider.isSimpleLink(DOMSpider.java:144)
at DOMSpider.findLinks(DOMSpider.java:93)
at DOMSpider.findLinks(DOMSpider.java:116)
at DOMSpider.findLinks(DOMSpider.java:116)
at DOMSpider.spider(DOMSpider.java:52)
at DOMSpider.main(DOMSpider.java:165)

The relevant code is..

Line where program breaks is
<link href="xrd.css" type="text/css" rel="stylesheet"/>

I could not understand why program breaks at this link element. Is it because of "type" attribute which we are actually trying to retrieve in program and check for "simple" link type or is it because of other reason?

Any input is greatly appreciated.

Thanks,
Satish.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getAttributeNS() method in Element interface returns "The Attr value as a string, or the empty string if that attribute does not have a specified or default value."

So is the exception thrown if we have a attribute and if that does'nt belong to namespace specified in method?

Thanks,
Satish.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic