xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Piyush Rai <raights...@yahoo.com>
Subject NullPointerException while setting attributes
Date Wed, 30 Jun 2004 09:38:43 GMT

I have a NodeList of path elements in an SVG file. 
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; 
NodeList paths = document.getElementsByTagNameNS(svgNS,"path"); 

I am also creating an equal number of empty paths(by setting 'd' attribute as ""). 

numberOfPaths = paths.getLength(); 
path = new Element[numberOfPaths]; 

Now I want to set other attributes of these new paths to that of original paths(from the SVG
file itself, instead of constant values). I am trying this(for example, the  "stroke" attribute):

NamedNodeMap namedNodes = paths.item(i).getAttributes(); 
//path[i].setAttributeNS(null, "stroke", "#00ffff");   THIS WORKS FINE 
path[i].setAttributeNS(svgNS, "stroke",namedNodes.getNamedItemNS(svgNS,"stroke").getNodeValue());

And similarly for other attributes. 

But I am getting NullPointerException. All the statements are in the order as written here.
What could be the reason for this? Any thoughts? 

Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
View raw message