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 dao <da...@gmail.com> on 2010/01/01 13:02:37 UTC

Re: create a JSVGCanvas from an inputstream

Added in [2]. not sure of how to reference the thread....

2009/12/30 Helder Magalhães <he...@gmail.com>

> Hi everyone,
>
>
> Response inline...
>
>
> (jonathan wood)
> >> Here are a couple of load routines I use frequently ..  Hope they help
> you
> >> narrow your problem.
>
> (dao)
> > Thank you, it works fine! I will keep those routine somewhere....
>
> In the wiki [1], perhaps...? ;-)
>
> The how-to section [2] seemed appropriate, but for shorter, useful
> code snippets, a dedicated page ("UsefulSnippets"?) would also be
> great! :-)
>
> BTW: if one decides to go with it, including a "taken from
> [link_to_mailing_list_thread here]" would be great so that one can
> crawl for background information if is curious enough.
>
>
> Cheers,
>  Helder
>
>
> [1] http://wiki.apache.org/xmlgraphics-batik/
> [2] http://wiki.apache.org/xmlgraphics-batik/HowTo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>


-- 
Dao Hodac

Re: create a JSVGCanvas from an inputstream

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

dao <da...@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 <da...@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 <he...@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
> [2] http://mail-archives.apache.org/mod_mbox/
> [3] 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
> 
> ---------------------------------------------------------------------
> 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

Re: create a JSVGCanvas from an inputstream

Posted by Martin Jacobson <ja...@gmail.com>.
I don't know whether this code is (a) relevant, (b) useful -- :-) --
but this is how I generate an SVG for the JSVGCanvas. I generate maps
by interrogating a spatial db (not shown), and placing the data into a
Velocity context (not shown, but called "ctx"). I pipe the output from
the Velocity engine into the "createSVGDocument()" method. The
PipedWriter must write in a different Thread from the PipedReader. It
works very well for me. I hope somebody finds it useful.

public void buildMap(JSVGCanvas svg) {
        // missing code (lots!)
	PipedReader r = new PipedReader();
	PipedWriter w = new PipedWriter(r);
	String prs = "org.apache.xerces.parsers.SAXParser";
	SAXSVGDocumentFactory fac = new SAXSVGDocumentFactory(prs);
	String templateName = "myTemplate.svg";
	new Thread(
		new Runnable() {
			public void run() {
				Velocity.mergeTemplate(templateName, "UTF8", ctx, w);
				w.close();
			}
		}
	).start();
	doc=fac.createSVGDocument("someURI", r);
	svg.setSVGDocument(doc);
}

Martin
-- 
>From my MacBook Pro

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


Re: create a JSVGCanvas from an inputstream

Posted by jonathan wood <jo...@gmail.com>.
There may be a way to do this "auto-magically", but I don't (yet) know it.

Try the jar protocol (jar:file://nn/file.svg)  (
http://docs.sun.com/source/819-0913/author/jar.html#jarprotocol)

Override/extend the existing UserAgent.openLink() functionality.  To save a
bit of hunting on your part...The appropriate code can be found in
JSVGComponent.BridgeUserAgent() (

You'll likely receive better guidance from the others on the list though.
I'll update you if I see something better.



On Sat, Jan 2, 2010 at 5:33 PM, dao <da...@gmail.com> wrote:

> I understand, but how can I refer to that document in an other document?
> (see the xlink:href from my mail)?
>
> 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 <da...@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 <he...@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
>>>> [2] http://mail-archives.apache.org/mod_mbox/
>>>> [3]
>>>> 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
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>

RE: create a JSVGCanvas from an inputstream

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

"HODAC, Olivier" <OL...@airbus.com> wrote on 01/04/2010 07:22:05 
AM:

> 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";

     This isn't a proper Jar file URL.  Please check the syntax of a
jar file URL.

> 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?

    Yes.

> 
> 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 <da...@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 <da...@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 <he...@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
> > [2] http://mail-archives.apache.org/mod_mbox/
> > [3] 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 
> > 
> > ---------------------------------------------------------------------
> > 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.


RE: create a JSVGCanvas from an inputstream

Posted by "HODAC, Olivier" <OL...@airbus.com>.
Sorry for the DOC_URI, it works fine now with

jar:/file:/E:/ATOLE/gate/animator/MoowClient.jar!/panel.svg

 

Just note that in a bat file, the ! is interpreted so the command line is like:

 

java -Djava.rmi.server.codebase=file:///F:/ATOLE/gate/animator/MoowClient.jar 

-Dsvg.document.URI="jar:file:///F:/ATOLE/gate/animator/MoowClient.jar^!/panel.svg" 

-Djava.rmi.server.hostname=TODA300038225 -Djava.security.policy=server.policy 

-cp MoowClient.jar com.moow.animator.engine.application.Main TODA300038225 %*

 

I add this to the wiki.

 

Thank's a lot for this thread

 

 

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

 

Hi Olivier, 

"HODAC, Olivier" <OL...@airbus.com> wrote on 01/04/2010 07:22:05 AM:

> 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 <file:///\\panel.svg\> "; 

     This isn't a proper Jar file URL.  Please check the syntax of a 
jar file URL. 

> 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? 

    Yes. 

>   
> De : thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com <ma...@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 <da...@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 <da...@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 <he...@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.

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.


RE: create a JSVGCanvas from an inputstream

Posted by "HODAC, Olivier" <OL...@airbus.com>.
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 <da...@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 <da...@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 <he...@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.


Re: create a JSVGCanvas from an inputstream

Posted by dao <da...@gmail.com>.
I understand, but how can I refer to that document in an other document?
(see the xlink:href from my mail)?

On Sat, Jan 2, 2010 at 11:27 PM, jonathan wood
<jo...@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 <da...@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 <he...@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
>>> [2] http://mail-archives.apache.org/mod_mbox/
>>> [3]
>>> 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
>>>
>>> ---------------------------------------------------------------------
>>> 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

Re: create a JSVGCanvas from an inputstream

Posted by jonathan wood <jo...@gmail.com>.
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 <da...@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 <he...@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
>> [2] http://mail-archives.apache.org/mod_mbox/
>> [3]
>> 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
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>>
>>
>
>
> --
> Dao Hodac
>

Re: create a JSVGCanvas from an inputstream

Posted by dao <da...@gmail.com>.
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 <he...@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
> [2] http://mail-archives.apache.org/mod_mbox/
> [3]
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>


-- 
Dao Hodac

Re: create a JSVGCanvas from an inputstream

Posted by Helder Magalhães <he...@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
[2] http://mail-archives.apache.org/mod_mbox/
[3] 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

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