This works in Squiggle...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'
[
<!ATTLIST rect
xmlns:my CDATA #FIXED "http://www.web.de/xzupftom"
my:Property CDATA #IMPLIED >
]>
<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("http://www.web.de/xzupftom",
"my:Property", "test");
}
</script>
<rect id="testnode" width="100" height="100" x="150" y="150"/>
</svg>
Look at the DOM when this has loaded, and you'll see the my:Property
attribute set to the value "test"
HTH
Martin
2009/11/2 Martin Jacobson <[email protected]>:
> Maybe the experts will come up with a better explanation, but this is
> the expected behaviour: the SVG DTD doesn't define a myProperty
> attribute for the rect element, so Batik (correctly) refuses to allow
> you to set its value - however, you can declare new attributes for
> most SVG elements (see the SVG specs for details). The fact that
> Firefox et al don't barf, is probably that they don't validate the
> SVG, merely test it for well-formedness.
>
> HTH
> Martin
>
>
> 2009/11/2 <[email protected]>:
>> Hi all,
>>
>> I asked the following question on the SVG-developers list, but I guess you
>> guys can help me better: Why is it impossible to add a property to a DOM
>> node with Batik? I have the following test SVG:
>>
>>
>> <?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.myProperty = "test"
>> alert(testnode.myProperty)
>> }
>> </script>
>> <rect id="testnode" width="100" height="100" x="150" y="150"/>
>> </svg>
>>
>>
>> It works perfectly in Firefox, Opera, IE+ASV and Safari, but Squiggle (Batik
>> 1.8pre+r801641) gives me the following Java error message:
>>
>> Java class "org.apache.batik.dom.svg.SVGOMRectElement" has no public
>> instance field or method named "myProperty". (Inline <script>
>> file:/E:/programmieren/svg/js/js_attribute_to_node_object_4.svg:6#4)
>>
>> Of course I can't dynamically add a property to a Java object, but this is
>> JavaScript, so I guess I should be able to add my custom properties. I
>> initially thought this could be Rhino's fault, but I threw the exact same
>> script into an HTML document and tested it with Lobo (AFAIK it uses Rhino as
>> well). This works as expected:
>>
>>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>> "http://www.w3.org/TR/html4/loose.dtd">
>> <html>
>> <head>
>> <script type="text/javascript">
>> init = function(){
>> testnode = document.getElementById("testnode")
>> testnode.myProperty = "test"
>> alert(testnode.myProperty)
>> }
>> </script>
>> </head>
>> <body onload="init()">
>> <p id="testnode">testnode</p>
>> </body>
>> </html>
>>
>>
>> Why aren't the Java DOM node objects properly wrapped as JavaScript objects?
>> Is this by purpose or just a missing feature?
>>
>> By the way, java -version on Windows XP gives me the following:
>> java version "1.6.0_13"
>> Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
>> Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode)
>>
>> Any info is greatly appreciated
>> Thomas Weber
>> ________________________________________________________________
>> DSL-Preisknaller: DSL-Komplettpakete schon für 16,99 Euro/mtl.!*
>> http://produkte.web.de/go/02/
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
>
> --
> From my MacBook Pro
>
--
>From my MacBook Pro
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]