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 Dale Ellis <da...@bt.com> on 2009/11/03 12:18:52 UTC

Re: Unknown language: text/ecmascript


thomas.deweese wrote:
> 
> 
> Did you include the resources directory?  In particular the
> resources/META-INF/services/org.apache.batik.script.InterpreterFactory
> is important for finding the ECMA Script interpreter.
> 
> 

Thanks for the reply, I thought no body had replied to this as I never
received an email maybe it was blocked, anyway not important.

That file existed in a few JAR files that are on the classpath but that file
was not in a resources folder itself. So I have extracted the file from one
of the jars. I have a folder called resources already which is on the build
path in eclipse and put the file
"org.apache.batik.script.InterpreterFactory" in there, that didn't work. So
under resources I tried adding directories "META-INF/services" and putting
it under there, that also didn't work. Both same error "Unknown language:
text/emcascript".

Any ideas? I did mention that the file you mention was in a few of the JAR
files, maybe they are causing a conflict with each other, I just added all
the jars onto classpath (listed at bottom), maybe I need to remove some?
Also how is that file picked up in the Batix code? just a resource bundle?
If I knew I could check my code can reference the file.

TIA,
Dale

batik-rasterizer.jar
batik-slideshow.jar
batik-squiggle.jar
batik-svgpp.jar
batik-ttf2svg.jar
batik.jar
batik-rasterizer-ext.jar
batik-squiggle-ext.jar
batik-anim.jar
batik-awt-util.jar
batik-bridge.jar
batik-codec.jar
batik-css.jar
batik-dom.jar
batik-ext.jar
batik-extension.jar
batik-gui-util.jar
batik-gvt.jar
batik-parser.jar
batik-script.jar
batik-svg-dom.jar
batik-svggen.jar
batik-swing.jar
batik-transcoder.jar
batik-util.jar
batik-xml.jar
js.jar
pdf-transcoder.jar
xalan-2.6.0.jar
xerces_2_5_0.jar
xml-apis-ext.jar
xml-apis.jar
-- 
View this message in context: http://old.nabble.com/Unknown-language%3A-text-ecmascript-tp25962063p26160071.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: Unknown language: text/ecmascript

Posted by Dale Ellis <da...@bt.com>.
Thanks for help Thomas,

I have narrowed it down to this in the Interpreter Pool and its because
svgDoc.getDocumentURI() is blank...

    public Interpreter createInterpreter(Document document, String language)
{
        InterpreterFactory factory =
(InterpreterFactory)factories.get(language);
        if (factory == null) return null;

        Interpreter interpreter = null;
        SVGOMDocument svgDoc = (SVGOMDocument) document;
        try {
            URL url = new URL(svgDoc.getDocumentURI());
            interpreter = factory.createInterpreter(url, svgDoc.isSVG12());
        } catch (MalformedURLException e) {
        }

        if (interpreter == null) return null;

        if (document != null)
            interpreter.bindObject(BIND_NAME_DOCUMENT, document);

        return interpreter;
    }


So why this needed?

If I go back to my code...

        try {
            // Parse the barChart.svg file into a Document.
            String parser = XMLResourceDescriptor.getXMLParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
                        
            GanttSVGXMLHandler gantthandler = new
GanttSVGXMLHandler("5YKPG", "HE3");
            //Reader reader = new StringReader(gantthandler.returnXML());
            Reader reader = new StringReader("<?xml version=\"1.0\"
standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\"
\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n<svg
width='100%' height='100%'><rect x='20' y='20' width='300' height='100'
style='fill:#DD3000;' onclick='alert(123456789);' /></svg>");
            
            doc = f.createDocument("", reader);

            svg = doc.getDocumentElement();

            // Make the text look nice.
            svg.setAttributeNS(null, "text-rendering",
"geometricPrecision");
        } catch (Exception ex) {
        }


I assumed thats picked up from        doc = f.createDocument("", reader);
and it as as if I enter somehting in there, when stepping the code in debug
svgDoc.getDocumentURI() has the calue I enter.

What am I supposed to set the URI to when the SVG document is not a physical
document on the file system??
-- 
View this message in context: http://old.nabble.com/Unknown-language%3A-text-ecmascript-tp25962063p26216586.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: Unknown language: text/ecmascript

Posted by Dale Ellis <da...@bt.com>.
Thanks Thomas for you time,

I have had a little play around with it, I got it working pointing at a
dummy svg file I added. However my Gantt chart svg which has alot of script
in it didn't like alot of the function calls.

I think I might have to create this dummy SVG with all the script I need in
it and maybe that will work, anyway lets of playing around with the code to
be done.

Thanks,
Dale
-- 
View this message in context: http://old.nabble.com/Unknown-language%3A-text-ecmascript-tp25962063p26266736.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: Unknown language: text/ecmascript

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

Dale Ellis <da...@bt.com> wrote on 11/05/2009 01:23:31 PM:

> I have narrowed it down to this in the Interpreter Pool and its because
> svgDoc.getDocumentURI() is blank...
> 
>             URL url = new URL(svgDoc.getDocumentURI());
>             interpreter = factory.createInterpreter(url, 
svgDoc.isSVG12());
> 
> So why this needed?

    The URL is used to construct the Rhino class loader, and I think
is used for script restrictions.  We should probably support simply
passing null for the URL, but mucking with the security stuff makes me
nervous.

> If I go back to my code...
>             doc = f.createDocument("", reader);

    batik.dom.svg.SVGOMDocument has methods:

    public void setURLObject(URL url);
    public void setParsedURL(ParsedURL url);

   That you can use to set the URL it will use.

> What am I supposed to set the URI to when the SVG document is not a 
physical
> document on the file system??

     Anything you want to.

Re: Unknown language: text/ecmascript

Posted by Dale Ellis <da...@bt.com>.
Thanks for help Thomas,

I have narrowed it down to this in the Interpreter Pool and its because
svgDoc.getDocumentURI() is blank...

    public Interpreter createInterpreter(Document document, String language)
{
        InterpreterFactory factory =
(InterpreterFactory)factories.get(language);
        if (factory == null) return null;

        Interpreter interpreter = null;
        SVGOMDocument svgDoc = (SVGOMDocument) document;
        try {
            URL url = new URL(svgDoc.getDocumentURI());
            interpreter = factory.createInterpreter(url, svgDoc.isSVG12());
        } catch (MalformedURLException e) {
        }

        if (interpreter == null) return null;

        if (document != null)
            interpreter.bindObject(BIND_NAME_DOCUMENT, document);

        return interpreter;
    }


So why this needed?

If I go back to my code...

        try {
            // Parse the barChart.svg file into a Document.
            String parser = XMLResourceDescriptor.getXMLParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
                        
            GanttSVGXMLHandler gantthandler = new
GanttSVGXMLHandler("5YKPG", "HE3");
            //Reader reader = new StringReader(gantthandler.returnXML());
            Reader reader = new StringReader("<?xml version=\"1.0\"
standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\"
\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n<svg
width='100%' height='100%'><rect x='20' y='20' width='300' height='100'
style='fill:#DD3000;' onclick='alert(123456789);' /></svg>");
            
            doc = f.createDocument("", reader);

            svg = doc.getDocumentElement();

            // Make the text look nice.
            svg.setAttributeNS(null, "text-rendering",
"geometricPrecision");
        } catch (Exception ex) {
        }


I assumed thats picked up from        doc = f.createDocument("", reader);
and it as as if I enter somehting in there, when stepping the code in debug
svgDoc.getDocumentURI() has the calue I enter.

What am I supposed to set the URI to when the SVG document is not a physical
document on the file system??
-- 
View this message in context: http://old.nabble.com/Unknown-language%3A-text-ecmascript-tp25962063p26216668.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: Unknown language: text/ecmascript

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

> thomas.deweese wrote:

> > Did you include the resources directory?  In particular the
> > resources/META-INF/services/org.apache.batik.script.InterpreterFactory
> > is important for finding the ECMA Script interpreter.

Dale Ellis <da...@bt.com> wrote on 11/03/2009 06:18:52 AM:

> Any ideas? I did mention that the file you mention was in a few of the 
JAR
> files, maybe they are causing a conflict with each other, I just added 
all
> the jars onto classpath (listed at bottom), maybe I need to remove some?

    I doubt it.

> Also how is that file picked up in the Batik code? just a resource 
bundle?
> If I knew I could check my code can reference the file.

    The code for Batik to locate the Service Provider is located in
batik.util.Service:
http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/Service.java?view=log

    Your best bet would be to add code either in that class or
in batik.script.InterpreterPool to see where things are going wrong.