xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "HODAC, Olivier" <OLIVIER.HO...@airbus.com>
Subject RE: create a JSVGCanvas from an inputstream
Date Mon, 04 Jan 2010 12:22:05 GMT
Hi,

 

I have tried your suggestion, but for the moment, it fails. 

 

I have created the document like this. Note that panel.svg does not exist:

         private static final String DOC_URI = "jar:file://panel.svg";

            ...

         String xmlDocument = remoteEngine.getSvgDocument();

         ByteArrayInputStream bais = new ByteArrayInputStream(xmlDocument.getBytes());

         String parser = XMLResourceDescriptor.getXMLParserClassName();

         SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);

 

         return f.createDocument(DOC_URI, bais);

 

In my jar (I run with: java -cp theJar.jar ...), I have a widget.svg file at the root if the
folder structure.

 

I get this error:

Unable to make sense of URL for connection (since I want to use a symbol set in the file widget.svg)

 

 

Is there a problem with the URI?

 

De : thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Envoyé : lundi 4 janvier 2010 12:27
À : batik-users@xmlgraphics.apache.org
Cc : batik-users@xmlgraphics.apache.org
Objet : Re: create a JSVGCanvas from an inputstream

 

Hi Dao, 

dao <dao.hodac@gmail.com> wrote on 01/02/2010 05:33:04 PM:

> I understand, but how can I refer to that document in an other 
> document? (see the xlink:href from my mail)? 

   After you have created your document from an InputStream 
you can set the base URL for the document.  There are two 
ways to do this, the 'xml:base' attribute or by calling 
batik.dom.svg.SVGOMDocument.setDocumentURI (or setURLObject, 
or setParsedURL). 

   I would suggest setting that URL to a JAR file URL that 
points to a non-existent file in your JAR, that is in the 
same directory as your 'widgets.svg' file.  Then if you 
use xlink:href="widgets.svg#blah" it will resolve the reference 
to the file in your Jar file. 

> On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood <jonathanshawwood@gmail.com
> > wrote: 
> Hi Dao,
> 
>   I also included a "load from jar" in the previous examples.  The 
> key is the line:
> 
>         InputStream templateStream = 
> MyClass.class.getResourceAsStream("template.svg");
> 
> getResourceAsStream will allow you to load from the classpath  
> (including your jar).
> 
> 
> to recap:
> 
>         InputStream templateStream = 
> MyClass.class.getResourceAsStream("template.svg"); 
> 
>         String parser = XMLResourceDescriptor.getXMLParserClassName();
>         SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
>         SVGDocument doc = null;
> 
>         try {
>             doc = f.createSVGDocument(null, templateStream);
>         } catch (IOException ex) {
>         }
> 
>        myCanvas.setSVGDocument(doc); 
> 
> On Sat, Jan 2, 2010 at 3:30 PM, dao <dao.hodac@gmail.com> wrote: 
> to continue with this inputstream document: 
> 
> My document that I build from an inputstream references an other 
> document by referencing some symbols (<use xlink:href="
> widgets.svg#warningMask" ...) 
> 
> How can I do to make this work: 
> 
> Either I create an other document I receive from my server which is 
> widget.svg and tell me how I can reference it (is it necessary to 
> create a file from the stream in the file widgets.svg?) 
> 
> Either I have the widgets.svg file in my application's jar. In that 
> case, How can I reference a file in a jar? 
> 
> Do you suggest me an other way to process? 
> 
> 2010/1/1 Helder Magalhães <helder.magalhaes@gmail.com> 
> 
> Hi dao,
> 
> 
> Response inline... 
> 
> 
> > Added in [2]. not sure of how to reference the thread....

> Great! :-)  I noticed an entry added to the how-to, but the actual
> page [1] doesn't exist yet...?
> 
> To reference a thread, just copy a link from the archives [2]. While
> using the official archives, the "trick" seems to be selecting the
> desired thread or particular message and clicking on the "Message
> view" link in order to get the desired thread/message hyperlink. In
> this particular case, it would be [3].
> 
> As we're at it, given than navigation/search features are not very
> user friendly in the official archives IMHO, I frequently use the
> Nabble archive [4], specially for searches... ;-)
> 
> 
> Hope this helps,
>  Helder
> 
> 
> [1] http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation <http://wiki.apache.org/xmlgraphics-batik/InputStreamInitialisation>

> [2] http://mail-archives.apache.org/mod_mbox/ <http://mail-archives.apache.org/mod_mbox/>

> [3] http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik- <http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik->

> users/200912.mbox/%
> 3C272595f40912300947w60080f76ibdc29c7a1a702602@mail.gmail.com%3E
> [4] http://old.nabble.com/Batik-f308.html <http://old.nabble.com/Batik-f308.html>
 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

> 
> 
> 
> -- 
> Dao Hodac 
> 
> 
> 
> 
> -- 
> Dao Hodac

This mail has originated outside your organization, either from an external partner or the
Global Internet.
Keep this in mind if you answer this message.
 

The information in this e-mail is confidential. The contents may not be disclosed or used
by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as
it has been sent over public networks. If you have any concerns over the content of this message
or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software
but you should take whatever measures you deem to be appropriate to ensure that this message
and any attachments are virus free.


Mime
View raw message