> -----Ursprüngliche Nachricht-----
> Von: "Martin Jacobson" <[email protected]>

> I see what you mean, but the problem is, the properties of a DOM node
> object ARE the attributes of the XML node!


Sorry, but I doubt that.  Take the following example:

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>

<svg version="1.1" xmlns="http://www.w3.org/2000/svg"; onload="init()">
  <script type="text/javascript">
    init = function(){
      testnode = document.getElementById("testnode")
      alert(testnode.fill)
      alert(testnode.getAttributeNS(null,"fill"))
      testnode.fill="red"
    }
  </script>
  <rect id="testnode" fill="black" width="100" height="100" x="150" y="150"/>
</svg>


If you were right, then alert(testnode.fill) should say "black", but it 
doesn't.  Neither with Batik nor in any Browser I tested.  Likewise, 
testnode.fill="red" should change the rect's color to red, but it doesn't.  I 
get the familiar error message:

Java class "org.apache.batik.dom.svg.SVGOMRectElement" has no public instance 
field or method named "fill". (Inline <script> 
file://localhost/E:/programmieren/svg/js/js_attribute_to_node_object_4.svg:6#6)

> Adding an arbitrary
> Javascript property to a DOM node is the same thing as adding that
> attribute to the XML node, so if that attribute isn't allowed by the
> DTD, I guess Batik is - unfortunately for you! - correct to disallow
> it.

According to the DTD, the fill attribute is allowed, but Batik still doesn't 
accept it.  On the other hand, Batik allows me to add an XML attribute to the 
rect node that, according to the DTD, isn't allowed:


<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>

<svg version="1.1" xmlns="http://www.w3.org/2000/svg"; onload="init()">
  <script type="text/javascript">
    init = function(){
      testnode = document.getElementById("testnode")
      testnode.setAttributeNS(null,"myAttribute","test")
      alert(testnode.getAttributeNS(null,"myAttribute"))
    }
  </script>
  <rect id="testnode" fill="black" width="100" height="100" x="150" y="150"/>
</svg>


> As a practical alternative, can't you define an object that *contains*
> the DOM node, plus any other properties you may wish to add?
> 

Certainly, I can work around this.  But I still would like to clarify whether 
this is a bug in Batik or on purpose.  Sorry if I'm becoming stubborn, but I 
really want to understand what's right and wrong in this context.

Thomas W.
______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to