Greetings,

I'd like to be able to determine what styles are in effect for a given
element in an SVGDocument.  I'm trying to use
ViewCSS.getComputedStyle(Element, pseudoElt) for this.

First, I'm not sure this is the correct approach, and second, I'm
getting NullPointerException errors on just about any method used on
the resulting CSSStyleDeclaration.  A small example demonstrating this
problem can be found at:

   http://erudycja.rutgers.edu/~armhold/cssbug/CSSBug.java

along with a simple SVG file that tickles it:

   http://erudycja.rutgers.edu/~armhold/cssbug/cssbug.svg

Here's a small synopsis of what I'm trying to do:

     NodeList nodeList = doc.getElementsByTagName("tspan");
     for (int i = 0; i < nodeList.getLength(); i++) {
       Element node = (Element) nodeList.item(i);

       CSSStyleDeclaration decl =
        ((ViewCSS) root).getComputedStyle(node, null);

       if (decl != null) {
        for (int j = 0; j < decl.getLength(); j++) { // this results in 
NullPointerException
          //    decl.getPropertyCSSValue() and decl.getCssText() also fail
          String s = decl.item(j);
          System.out.println("style item: " + s);
        }
       }
     }


I'm getting the following not very helpful stack trace:

Exception in thread "main" java.lang.NullPointerException
         at 
org.apache.batik.css.dom.CSSOMComputedStyle.getLength(Unknown Source)
         at CSSBug.main(CSSBug.java:40)

I'm using Batik 1.5b4 and JDK 1.4 under Redhat Linux 7.2.

Any help greatly appreciated.

--
George Armhold
Rutgers University
eLearning Grant, DCIS


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to