You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by "Fennell, Philip" <ph...@hp.com> on 2006/07/19 11:16:34 UTC

Scripts within nested SVGs being ignored.

Now that I have js.jar on my classpath I've got my ecmascript running
happily, but...

In the application I'm working on a 'background/canvas' SVG document is
loaded into JSVGCanvas when the application launches.
Then I select and open another SVG document who's documentElement is
imported into the 'canvas' document and inserted into the 'canvas'.

The inner SVG has a script element with a function that is called from
an onclick event in the inner SVG. When I click on the primitive in the
view I get the error listed below. If I move the script element up into
the top level (parent) SVG, the 'canvas', then the script runs happily.

Is there a reason why Batik ignores script declarations in descendant
svg elements?



Stacktrace:
===========

org.mozilla.javascript.EcmaError: ReferenceError: "setColour" is not
defined. (Event attribute null:-1 onclick#1)
	at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
226)
	at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
216)
	at
org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:32
89)
	at
org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntim
e.java:1891)
	at
org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:93)
	at org.mozilla.javascript.gen.c1._c0(Event attribute null:-1
onclick:1)
	at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
onclick)
	at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
	at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
	at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
onclick)
	at org.mozilla.javascript.gen.c1.exec(Event attribute null:-1
onclick)
	at
org.mozilla.javascript.Context.evaluateReader(Context.java:1163)
	at
org.apache.batik.script.rhino.RhinoInterpreter.evaluate(Unknown Source)
	at
org.apache.batik.bridge.ScriptingEnvironment.runEventHandler(Unknown
Source)
	at
org.apache.batik.bridge.ScriptingEnvironment$ScriptingEventListener.hand
leEvent(Unknown Source)
	at
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
Source)
	at
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
Source)
	at
org.apache.batik.dom.events.EventSupport.dispatchEvent(Unknown Source)
	at org.apache.batik.dom.AbstractNode.dispatchEvent(Unknown
Source)
	at
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
nknown Source)
	at
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
nknown Source)
	at
org.apache.batik.bridge.BridgeEventSupport$Listener.mouseClicked(Unknown
Source)
	at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.processMouseEvent(
Unknown Source)
	at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchMouseEvent
(Unknown Source)
	at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchEvent(Unkn
own Source)
	at
org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(Unknown
Source)
	at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.mouseClicked(Unkno
wn Source)
	at
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener$12.run(Unkn
own Source)
	at org.apache.batik.util.RunnableQueue.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:595)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: Scripts within nested SVGs being ignored.

Posted by "jeff.cressman" <je...@gmail.com>.
Hi,

Apologies, I didn't see this post earlier:
http://www.nabble.com/Reg%3A-Accessing-SVG-DOM-tree-using-Java-to867651.html#a879225.
The example given there clarified for me what Thomas meant by evaling the
text content of script nodes. For the workaround I wasn't getting that the
script nodes actually contain the script. I'm working with script elements
that link to javascript files and wasn't understanding how you would
evaluate a link.

I ended up using the approach given at
http://mcc.id.au/2007/09/batik-course/, section 45 "Evaluating Script from
Java", in the following way. Note: when I used getElementsByTagNameNS as
suggested in the workaround it didn't return any elements.

                        // After adding a subtree to the main svg document
any scripts
                        // in the subtree are evaluated
                        NodeList nScript =
doc.getElementsByTagName("script");
                        FileReader scriptReader;
                        String path;
                        for (int i = 0; i < nScript.getLength(); i++) {
                            // skip the first one as it's the script from
the original svg doc
                            if (i > 0) {
                                try {
                                    path = ((Element)
nScript.item(i)).getAttributeNS("http://www.w3.org/1999/xlink", "href");
                                    // strip "file:"
                                    path = path.substring(5);
                                    scriptReader = new FileReader(path);
                                    canvas.evaluateInES(scriptReader); //
the extended JSVGCanvas
                                } catch (Exception ex) {
                                    ex.printStackTrace();
                                }
                            }
                        }

Regards,
Jeff Cressman


jeff.cressman wrote:
> 
> Hi Thomas,
> 
> I am writing similar code where I want to add svg elements containing
> script elements to a previously loaded document. I don't quite understand
> the workaround. If you could explain it in a little more detail I would be
> grateful. Are you suggesting that the new subtree gets searched from a
> script loaded with the original document or from the java code that adds
> the subtree? Once the script elements are identified I don't understand
> what is meant by "eval"ing them. If my script element is <script
> xlink:href="circle.js"/> then do I eval the whole element or just the
> xlink:href="circle.js" portion?
> 
> Thanks,
> Jeff Cressman
> 
> 
> thomas.deweese wrote:
>> 
>> 
>>    BTW you can probably fix this in your script by searching the 
>> 'too be added' subtree for script elements (getElementsByTagNameNS)
>> and simply "eval"ing the text content of them (I say simply but
>> the text content is likely split across multiple text nodes).
>> Anyway it's a potential workaround if you need one.
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/svg%3Ascript-error...-tp5380680p15079154.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: Scripts within nested SVGs being ignored.

Posted by "jeff.cressman" <je...@gmail.com>.
Hi Thomas,

I am writing similar code where I want to add svg elements containing script
elements to a previously loaded document. I don't quite understand the
workaround. If you could explain it in a little more detail I would be
grateful. Are you suggesting that the new subtree gets searched from a
script loaded with the original document or from the java code that adds the
subtree? Once the script elements are identified I don't understand what is
meant by "eval"ing them. If my script element is <script
xlink:href="circle.js"/> then do I eval the whole element or just the
xlink:href="circle.js" portion?

Thanks,
Jeff Cressman


thomas.deweese wrote:
> 
> 
>    BTW you can probably fix this in your script by searching the 
> 'too be added' subtree for script elements (getElementsByTagNameNS)
> and simply "eval"ing the text content of them (I say simply but
> the text content is likely split across multiple text nodes).
> Anyway it's a potential workaround if you need one.
> 
> 

-- 
View this message in context: http://www.nabble.com/svg%3Ascript-error...-tp5380680p15072528.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: Scripts within nested SVGs being ignored.

Posted by "Fennell, Philip" <ph...@hp.com>.
Thomas,

Thanks for the tip.

I will enter a bug against this.




Regards

Philip Fennell 

-----Original Message-----
From: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Sent: 20 July 2006 10:45
To: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Subject: RE: Scripts within nested SVGs being ignored.

Hi Philip,

"Fennell, Philip" <ph...@hp.com> wrote on 07/20/2006 03:09:09
AM:

> I have checked the SVG 1.1 spec and there does not seem to be any 
> restrictions on placement of script elements, so I am assuming that 
> Batik should not be ignoring script elements in nested SVGs.

   I don't think it has anything to do with nested SVG's.  I think we
ignore any script element added after initial document construction.

> If you, or anyone else, agrees with me that this behavior is 
> incorrect, then I will raise a bug and attach my test case.

   Please do.

   BTW you can probably fix this in your script by searching the 'too be
added' subtree for script elements (getElementsByTagNameNS) and simply
"eval"ing the text content of them (I say simply but the text content is
likely split across multiple text nodes).
Anyway it's a potential workaround if you need one.


> From: Mark A Fortner [mailto:phidias51@yahoo.com] 
> Sent: 20 July 2006 04:15
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: Scripts within nested SVGs being ignored.
> 
> 
> My guess is that the spelling of "setColour" isn't recognized.  Try
the
> American spelling and see if that works. 
> 
> Mark
> 
> "Fennell, Philip" <ph...@hp.com> wrote: 
> 
>    Now that I have js.jar on my classpath I've got my ecmascript
> running
>    happily, but...
> 
>    In the application I'm working on a 'background/canvas' SVG
> document is
>    loaded into JSVGCanvas when the application launches.
>    Then I select and open another SVG document who's
> documentElement is
>    imported into the 'canvas' document and inserted into the
> 'canvas'.
> 
>    The inner SVG has a script element with a function that is
> called from
>    an onclick event in the inner SVG. When I click on the primitive
> in the
>    view I get the error listed below. If I move the script element
> up into
>    the top level (parent) SVG, the 'canvas', then the script runs
> happily.
> 
>    Is there a reason why Batik ignores script declarations in
> descendant
>    svg elements?
> 
> 
> 
>    Stacktrace:
>    ===========
> 
>    org.mozilla.javascript.EcmaError: ReferenceError: "setColour" is
> not
>    defined. (Event attribute null:-1 onclick#1)
>    at
> 
>
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
>    226)
>    at
> 
>
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
>    216)
>    at
> 
>
org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:32
>    89)
>    at
> 
>
org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntim
>    e.java:1891)
>    at
> 
>
org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:93)
>    at org.mozilla.javascript.gen.c1._c0(Event attribute null:-1
>    onclick:1)
>    at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
>    onclick)
>    at
> 
>
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
>    at
> 
>
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
>    at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
>    onclick)
>    at org.mozilla.javascript.gen.c1.exec(Event attribute null:-1
>    onclick)
>    at
>    org.mozilla.javascript.Context.evaluateReader(Context.java:1163)
>    at
>    org.apache.batik.script.rhino.RhinoInterpreter.evaluate(Unknown
> Source)
>    at
> 
> org.apache.batik.bridge.ScriptingEnvironment.runEventHandler(Unknown
>    Source)
>    at
> 
>
org.apache.batik.bridge.ScriptingEnvironment$ScriptingEventListener.hand
>    leEvent(Unknown Source)
>    at
> 
> org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
>    Source)
>    at
> 
> org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
>    Source)
>    at
>    org.apache.batik.dom.events.EventSupport.dispatchEvent(Unknown
> Source)
>    at org.apache.batik.dom.AbstractNode.dispatchEvent(Unknown
>    Source)
>    at
> 
>
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
>    nknown Source)
>    at
> 
>
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
>    nknown Source)
>    at
> 
>
org.apache.batik.bridge.BridgeEventSupport$Listener.mouseClicked(Unknown
>    Source)
>    at
> 
>
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.processMouseEvent(
>    Unknown Source)
>    at
> 
>
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchMouseEvent
>    (Unknown Source)
>    at
> 
>
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchEvent(Unkn
>    own Source)
>    at
> 
> org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(Unknown
>    Source)
>    at
> 
>
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.mouseClicked(Unkno
>    wn Source)
>    at
> 
>
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener$12.run(Unkn
>    own Source)
>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>    at java.lang.Thread.run(Thread.java:595)
> 
> 
> ---------------------------------------------------------------------
>    To unsubscribe, e-mail:
> batik-users-unsubscribe@xmlgraphics.apache.org
>    For additional commands, e-mail:
> batik-users-help@xmlgraphics.apache.org
> 
> 
> 
> 
> ________________________________
> 
> Do you Yahoo!?
> Next-gen email? Have it all with the all-new Yahoo! Mail Beta.
>
<http://us.rd.yahoo.com/evt=42241/*http://advision.webevents.yahoo.com/h
> andraisers> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: Scripts within nested SVGs being ignored.

Posted by th...@kodak.com.
Hi Philip,

"Fennell, Philip" <ph...@hp.com> wrote on 07/20/2006 03:09:09 AM:

> I have checked the SVG 1.1 spec and there does not seem to be any
> restrictions on placement of script elements, so I am assuming that
> Batik should not be ignoring script elements in nested SVGs.

   I don't think it has anything to do with nested SVG's.  I
think we ignore any script element added after initial document
construction.

> If you, or anyone else, agrees with me that this behavior is incorrect,
> then I will raise a bug and attach my test case.

   Please do.

   BTW you can probably fix this in your script by searching the 
'too be added' subtree for script elements (getElementsByTagNameNS)
and simply "eval"ing the text content of them (I say simply but
the text content is likely split across multiple text nodes).
Anyway it's a potential workaround if you need one.


> From: Mark A Fortner [mailto:phidias51@yahoo.com] 
> Sent: 20 July 2006 04:15
> To: batik-users@xmlgraphics.apache.org
> Subject: Re: Scripts within nested SVGs being ignored.
> 
> 
> My guess is that the spelling of "setColour" isn't recognized.  Try the
> American spelling and see if that works. 
> 
> Mark
> 
> "Fennell, Philip" <ph...@hp.com> wrote: 
> 
>    Now that I have js.jar on my classpath I've got my ecmascript
> running
>    happily, but...
> 
>    In the application I'm working on a 'background/canvas' SVG
> document is
>    loaded into JSVGCanvas when the application launches.
>    Then I select and open another SVG document who's
> documentElement is
>    imported into the 'canvas' document and inserted into the
> 'canvas'.
> 
>    The inner SVG has a script element with a function that is
> called from
>    an onclick event in the inner SVG. When I click on the primitive
> in the
>    view I get the error listed below. If I move the script element
> up into
>    the top level (parent) SVG, the 'canvas', then the script runs
> happily.
> 
>    Is there a reason why Batik ignores script declarations in
> descendant
>    svg elements?
> 
> 
> 
>    Stacktrace:
>    ===========
> 
>    org.mozilla.javascript.EcmaError: ReferenceError: "setColour" is
> not
>    defined. (Event attribute null:-1 onclick#1)
>    at
> 
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
>    226)
>    at
> 
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
>    216)
>    at
> 
> org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:32
>    89)
>    at
> 
> org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntim
>    e.java:1891)
>    at
> 
> org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:93)
>    at org.mozilla.javascript.gen.c1._c0(Event attribute null:-1
>    onclick:1)
>    at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
>    onclick)
>    at
> 
> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
>    at
> 
> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
>    at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
>    onclick)
>    at org.mozilla.javascript.gen.c1.exec(Event attribute null:-1
>    onclick)
>    at
>    org.mozilla.javascript.Context.evaluateReader(Context.java:1163)
>    at
>    org.apache.batik.script.rhino.RhinoInterpreter.evaluate(Unknown
> Source)
>    at
> 
> org.apache.batik.bridge.ScriptingEnvironment.runEventHandler(Unknown
>    Source)
>    at
> 
> org.apache.batik.bridge.ScriptingEnvironment$ScriptingEventListener.hand
>    leEvent(Unknown Source)
>    at
> 
> org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
>    Source)
>    at
> 
> org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
>    Source)
>    at
>    org.apache.batik.dom.events.EventSupport.dispatchEvent(Unknown
> Source)
>    at org.apache.batik.dom.AbstractNode.dispatchEvent(Unknown
>    Source)
>    at
> 
> org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
>    nknown Source)
>    at
> 
> org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
>    nknown Source)
>    at
> 
> org.apache.batik.bridge.BridgeEventSupport$Listener.mouseClicked(Unknown
>    Source)
>    at
> 
> org.apache.batik.gvt.event.AbstractAWTEventDispatcher.processMouseEvent(
>    Unknown Source)
>    at
> 
> org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchMouseEvent
>    (Unknown Source)
>    at
> 
> org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchEvent(Unkn
>    own Source)
>    at
> 
> org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(Unknown
>    Source)
>    at
> 
> org.apache.batik.gvt.event.AbstractAWTEventDispatcher.mouseClicked(Unkno
>    wn Source)
>    at
> 
> org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener$12.run(Unkn
>    own Source)
>    at org.apache.batik.util.RunnableQueue.run(Unknown Source)
>    at java.lang.Thread.run(Thread.java:595)
> 
> 
> ---------------------------------------------------------------------
>    To unsubscribe, e-mail:
> batik-users-unsubscribe@xmlgraphics.apache.org
>    For additional commands, e-mail:
> batik-users-help@xmlgraphics.apache.org
> 
> 
> 
> 
> ________________________________
> 
> Do you Yahoo!?
> Next-gen email? Have it all with the all-new Yahoo! Mail Beta.
> <http://us.rd.yahoo.com/evt=42241/*http://advision.webevents.yahoo.com/h
> andraisers> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


RE: Scripts within nested SVGs being ignored.

Posted by "Fennell, Philip" <ph...@hp.com>.
Mark,
 
The function 'setColour' is one that I have declared in the script
element of the nested svg, and the spellings of caller and callee are
both correct.
 
I have checked the SVG 1.1 spec and there does not seem to be any
restrictions on placement of script elements, so I am assuming that
Batik should not be ignoring script elements in nested SVGs.

If you, or anyone else, agrees with me that this behaviour is incorrect,
then I will raise a bug and attach my test case.



Regards

Philip Fennell 


________________________________

From: Mark A Fortner [mailto:phidias51@yahoo.com] 
Sent: 20 July 2006 04:15
To: batik-users@xmlgraphics.apache.org
Subject: Re: Scripts within nested SVGs being ignored.


My guess is that the spelling of "setColour" isn't recognized.  Try the
American spelling and see if that works.  

Mark

"Fennell, Philip" <ph...@hp.com> wrote: 

	Now that I have js.jar on my classpath I've got my ecmascript
running
	happily, but...
	
	In the application I'm working on a 'background/canvas' SVG
document is
	loaded into JSVGCanvas when the application launches.
	Then I select and open another SVG document who's
documentElement is
	imported into the 'canvas' document and inserted into the
'canvas'.
	
	The inner SVG has a script element with a function that is
called from
	an onclick event in the inner SVG. When I click on the primitive
in the
	view I get the error listed below. If I move the script element
up into
	the top level (parent) SVG, the 'canvas', then the script runs
happily.
	
	Is there a reason why Batik ignores script declarations in
descendant
	svg elements?
	
	
	
	Stacktrace:
	===========
	
	org.mozilla.javascript.EcmaError: ReferenceError: "setColour" is
not
	defined. (Event attribute null:-1 onclick#1)
	at
	
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
	226)
	at
	
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
	216)
	at
	
org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:32
	89)
	at
	
org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntim
	e.java:1891)
	at
	
org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:93)
	at org.mozilla.javascript.gen.c1._c0(Event attribute null:-1
	onclick:1)
	at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
	onclick)
	at
	
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
	at
	
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
	at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
	onclick)
	at org.mozilla.javascript.gen.c1.exec(Event attribute null:-1
	onclick)
	at
	org.mozilla.javascript.Context.evaluateReader(Context.java:1163)
	at
	org.apache.batik.script.rhino.RhinoInterpreter.evaluate(Unknown
Source)
	at
	
org.apache.batik.bridge.ScriptingEnvironment.runEventHandler(Unknown
	Source)
	at
	
org.apache.batik.bridge.ScriptingEnvironment$ScriptingEventListener.hand
	leEvent(Unknown Source)
	at
	
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
	Source)
	at
	
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
	Source)
	at
	org.apache.batik.dom.events.EventSupport.dispatchEvent(Unknown
Source)
	at org.apache.batik.dom.AbstractNode.dispatchEvent(Unknown
	Source)
	at
	
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
	nknown Source)
	at
	
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
	nknown Source)
	at
	
org.apache.batik.bridge.BridgeEventSupport$Listener.mouseClicked(Unknown
	Source)
	at
	
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.processMouseEvent(
	Unknown Source)
	at
	
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchMouseEvent
	(Unknown Source)
	at
	
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchEvent(Unkn
	own Source)
	at
	
org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(Unknown
	Source)
	at
	
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.mouseClicked(Unkno
	wn Source)
	at
	
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener$12.run(Unkn
	own Source)
	at org.apache.batik.util.RunnableQueue.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:595)
	
	
---------------------------------------------------------------------
	To unsubscribe, e-mail:
batik-users-unsubscribe@xmlgraphics.apache.org
	For additional commands, e-mail:
batik-users-help@xmlgraphics.apache.org
	
	


________________________________

Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail Beta.
<http://us.rd.yahoo.com/evt=42241/*http://advision.webevents.yahoo.com/h
andraisers> 

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Scripts within nested SVGs being ignored.

Posted by Mark A Fortner <ph...@yahoo.com>.
My guess is that the spelling of "setColour" isn't recognized.  Try the American spelling and see if that works.  

Mark

"Fennell, Philip" <ph...@hp.com> wrote: Now that I have js.jar on my classpath I've got my ecmascript running
happily, but...

In the application I'm working on a 'background/canvas' SVG document is
loaded into JSVGCanvas when the application launches.
Then I select and open another SVG document who's documentElement is
imported into the 'canvas' document and inserted into the 'canvas'.

The inner SVG has a script element with a function that is called from
an onclick event in the inner SVG. When I click on the primitive in the
view I get the error listed below. If I move the script element up into
the top level (parent) SVG, the 'canvas', then the script runs happily.

Is there a reason why Batik ignores script declarations in descendant
svg elements?



Stacktrace:
===========

org.mozilla.javascript.EcmaError: ReferenceError: "setColour" is not
defined. (Event attribute null:-1 onclick#1)
 at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
226)
 at
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3
216)
 at
org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:32
89)
 at
org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntim
e.java:1891)
 at
org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:93)
 at org.mozilla.javascript.gen.c1._c0(Event attribute null:-1
onclick:1)
 at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
onclick)
 at
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
 at
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
 at org.mozilla.javascript.gen.c1.call(Event attribute null:-1
onclick)
 at org.mozilla.javascript.gen.c1.exec(Event attribute null:-1
onclick)
 at
org.mozilla.javascript.Context.evaluateReader(Context.java:1163)
 at
org.apache.batik.script.rhino.RhinoInterpreter.evaluate(Unknown Source)
 at
org.apache.batik.bridge.ScriptingEnvironment.runEventHandler(Unknown
Source)
 at
org.apache.batik.bridge.ScriptingEnvironment$ScriptingEventListener.hand
leEvent(Unknown Source)
 at
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
Source)
 at
org.apache.batik.dom.events.EventSupport.fireEventListeners(Unknown
Source)
 at
org.apache.batik.dom.events.EventSupport.dispatchEvent(Unknown Source)
 at org.apache.batik.dom.AbstractNode.dispatchEvent(Unknown
Source)
 at
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
nknown Source)
 at
org.apache.batik.bridge.BridgeEventSupport$Listener.dispatchMouseEvent(U
nknown Source)
 at
org.apache.batik.bridge.BridgeEventSupport$Listener.mouseClicked(Unknown
Source)
 at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.processMouseEvent(
Unknown Source)
 at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchMouseEvent
(Unknown Source)
 at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchEvent(Unkn
own Source)
 at
org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(Unknown
Source)
 at
org.apache.batik.gvt.event.AbstractAWTEventDispatcher.mouseClicked(Unkno
wn Source)
 at
org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener$12.run(Unkn
own Source)
 at org.apache.batik.util.RunnableQueue.run(Unknown Source)
 at java.lang.Thread.run(Thread.java:595)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org



 		
---------------------------------
Do you Yahoo!?
 Next-gen email? Have it all with the  all-new Yahoo! Mail Beta.