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 Arian Hojat <ar...@gmail.com> on 2005/04/06 00:07:11 UTC

Re: SVG Xlink:href element within a Document.... tags doesnt seem to render in Batik?

Hey Tonny and all,

thanx for the help. my code compiles now, but the image that shows up
seems to be a default Batik image instead of the ones i use. Batik
seems to find my images as no 'FileNotFoundException' gets returned
but i get this broken link? vector-y image?....
http://www.pages.drexel.edu/~ah49/blah.jpg
when it should look like this (exported from my svg editor from the
svg source that is creating the image, saved in my java program so i
know batik has good code to work with):
http://www.pages.drexel.edu/~ah49/source.png

my Batik code if it helps is @
http://www.pages.drexel.edu/~ah49/Main.java
and the images i overlay are:
http://www.pages.drexel.edu/~ah49/a.jpg
http://www.pages.drexel.edu/~ah49/w.png

thanx if anyone can help me understand what is being made by batik here.




Tonny Kohar <to...@kiyut.com> wrote:
Hi,

On Mon, 2005-04-04 at 02:10 -0400, Arian Hojat wrote:
> [snip] 
> 
> Element image1 =
> svgDoc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
> "image");
> image1.setAttributeNS(null, "xlink:href", "a.jpg"); 

Change this to image1.setAttributeNS(xlinkNS,"xlink:href", "a.jpg");
Note: for this part do not use null as namespace.
You could use the defined constants at
org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI or just type the
whole namespace.

> image1.setAttributeNS(null, "x", "0");
> image1.setAttributeNS(null, "y", "0");
> image1.setAttributeNS(null, "width", "100%");
> image1.setAttributeNS(null, "height","100%");

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


---------------------------------------------------------------------
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: SVG Xlink:href element within a Document.... tags doesnt seem to render in Batik?

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Arian, Tonny,

>>Thomas was right about the broken links...
>>[very weird since it does not report a fileNotFoundException].

    If it threw a fileNotFoundException you wouldn't get
a rendering.  I believe the user agent is notified at
some point.

>>when i use a full url path like below, it works...
>>[...] i need to work with relative urls...
> 

Tonny Kohar wrote:

> For the info Batik is work fine with both Absolute and Relative URI.
> 
> Some tips regarding Relative URI:
> - make sure the document base URL is correct, otherwise it couldn't
> resolve the relative path. This is normally become a problem if you
> create the document on fly rather than load from file.

    This is almost certainly the problem here.
    When you create the TranscoderInput you can provide a
uri to use as the base URI of the document being transcoded:
	TranscoderInput.setURI(String uri)

    You can also use the 'xml:base' attribute on elements in the
document to set the base URI for URL resolution.

> - Do not forget the set xlink namespace in the element that required it
> eg: image
> - To keep things simpler (during development debuging) try to put the
> relative external resources in the same dir as the doc, however batik
> relative URI is work fine in any arbitary dir
> 
> Regards
> Tonny Kohar


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


Re: SVG Xlink:href element within a Document.... tags doesnt seem to render in Batik?

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

> Thomas was right about the broken links...
> [very weird since it does not report a fileNotFoundException].
> when i use a full url path like below, it works...
> image1.setAttributeNS(
> org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI , "xlink:href",
> "file:\\\\\\C:\\Documents and
> Settings\\Administrator\\Desktop\\SVGTest\\build\\a.jpg");
> 
> this is kinda 'ghetto' though and i am gonna be maybe sending these
> svg and pics files to the user with a saveSVGAandSourcePicsZip()
> function probably.so i need to work with relative urls...

For the info Batik is work fine with both Absolute and Relative URI.

Some tips regarding Relative URI:
- make sure the document base URL is correct, otherwise it couldn't
resolve the relative path. This is normally become a problem if you
create the document on fly rather than load from file.
- Do not forget the set xlink namespace in the element that required it
eg: image
- To keep things simpler (during development debuging) try to put the
relative external resources in the same dir as the doc, however batik
relative URI is work fine in any arbitary dir

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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


Re: SVG Xlink:href element within a Document.... tags doesnt seem to render in Batik?

Posted by Arian Hojat <ar...@gmail.com>.
hey,
Thomas was right about the broken links...
[very weird since it does not report a fileNotFoundException].
when i use a full url path like below, it works...
image1.setAttributeNS(
org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI , "xlink:href",
"file:\\\\\\C:\\Documents and
Settings\\Administrator\\Desktop\\SVGTest\\build\\a.jpg");

this is kinda 'ghetto' though and i am gonna be maybe sending these
svg and pics files to the user with a saveSVGAandSourcePicsZip()
function probably.so i need to work with relative urls...

this is a simple 'create svg' and 'save Jpeg' program. but it will be
used in a larger school project i am doing and i am a bit frustrated
since my groupmates depend on me for the SVG parts.

my last request is if anyone wants to solve my problem...
if anyone is very good at java, maybe Main.java which creates the svg
Doc and jpegs is phoeey somewhere or maybe my build script is fudging
up by not having a correct classpath (which i doubt since its in same
dir as the /build/Main.class file), who knows?
http://www.pages.drexel.edu/~ah49/SVGTest.zip (i left out the
batik*.jars from /lib since thats a hefty download; if u want to point
to your directory in the build.xml file's $lib property or copy and
paste your batik*.jars to /lib)

run 'ant run' or just click run if u know how to run ant scripts
within your java IDE to compile and run (saves the svg and jpeg to
/build, notice how the full-pathUrl image shows up but the
relative-url image does not)

thanx in advance if anyone can help more.














On Apr 5, 2005 8:56 PM, Thomas DeWeese <Th...@kodak.com> wrote:
> Arian Hojat wrote:
> 
> > thanx for the help. my code compiles now, but the image that shows up
> > seems to be a default Batik image instead of the ones i use. Batik
> > seems to find my images as no 'FileNotFoundException' gets returned
> > but i get this broken link? vector-y image?....
> 
>    The 'broken link' image is used when it can't load the referenced
> image.  So it is very possible that it can't find the referenced image.
> 
> > http://www.pages.drexel.edu/~ah49/blah.jpg
> > when it should look like this (exported from my svg editor from the
> > svg source that is creating the image, saved in my java program so i
> > know batik has good code to work with):
> 
>    Actually this is not a very good indicator that the DOM is
> good.  Many errors in the DOM can be fixed by writing it out and
> reading it back in.  In this case however I would suspect that
> something funky is going on with the reference to the
> external files.  Can you provide the SVG content?
> 
> > http://www.pages.drexel.edu/~ah49/source.png
> >
> > my Batik code if it helps is @
> > http://www.pages.drexel.edu/~ah49/Main.java
> > and the images i overlay are:
> > http://www.pages.drexel.edu/~ah49/a.jpg
> > http://www.pages.drexel.edu/~ah49/w.png
> >
> > thanx if anyone can help me understand what is being made by batik here.
> >
> >
> >
> >
> > Tonny Kohar <to...@kiyut.com> wrote:
> > Hi,
> >
> > On Mon, 2005-04-04 at 02:10 -0400, Arian Hojat wrote:
> >
> >>[snip]
> >>
> >>Element image1 =
> >>svgDoc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
> >>"image");
> >>image1.setAttributeNS(null, "xlink:href", "a.jpg");
> >
> >
> > Change this to image1.setAttributeNS(xlinkNS,"xlink:href", "a.jpg");
> > Note: for this part do not use null as namespace.
> > You could use the defined constants at
> > org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI or just type the
> > whole namespace.
> >
> >
> >>image1.setAttributeNS(null, "x", "0");
> >>image1.setAttributeNS(null, "y", "0");
> >>image1.setAttributeNS(null, "width", "100%");
> >>image1.setAttributeNS(null, "height","100%");
> >
> >
> > Regards
> > Tonny Kohar
> 
> ---------------------------------------------------------------------
> 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: SVG Xlink:href element within a Document.... tags doesnt seem to render in Batik?

Posted by Thomas DeWeese <Th...@Kodak.com>.
Arian Hojat wrote:

> thanx for the help. my code compiles now, but the image that shows up
> seems to be a default Batik image instead of the ones i use. Batik
> seems to find my images as no 'FileNotFoundException' gets returned
> but i get this broken link? vector-y image?....

    The 'broken link' image is used when it can't load the referenced
image.  So it is very possible that it can't find the referenced image.

> http://www.pages.drexel.edu/~ah49/blah.jpg
> when it should look like this (exported from my svg editor from the
> svg source that is creating the image, saved in my java program so i
> know batik has good code to work with):

    Actually this is not a very good indicator that the DOM is
good.  Many errors in the DOM can be fixed by writing it out and
reading it back in.  In this case however I would suspect that
something funky is going on with the reference to the
external files.  Can you provide the SVG content?

> http://www.pages.drexel.edu/~ah49/source.png
> 
> my Batik code if it helps is @
> http://www.pages.drexel.edu/~ah49/Main.java
> and the images i overlay are:
> http://www.pages.drexel.edu/~ah49/a.jpg
> http://www.pages.drexel.edu/~ah49/w.png
> 
> thanx if anyone can help me understand what is being made by batik here.
> 
> 
> 
> 
> Tonny Kohar <to...@kiyut.com> wrote:
> Hi,
> 
> On Mon, 2005-04-04 at 02:10 -0400, Arian Hojat wrote:
> 
>>[snip] 
>>
>>Element image1 =
>>svgDoc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
>>"image");
>>image1.setAttributeNS(null, "xlink:href", "a.jpg"); 
> 
> 
> Change this to image1.setAttributeNS(xlinkNS,"xlink:href", "a.jpg");
> Note: for this part do not use null as namespace.
> You could use the defined constants at
> org.apache.batik.util.XMLConstants.XLINK_NAMESPACE_URI or just type the
> whole namespace.
> 
> 
>>image1.setAttributeNS(null, "x", "0");
>>image1.setAttributeNS(null, "y", "0");
>>image1.setAttributeNS(null, "width", "100%");
>>image1.setAttributeNS(null, "height","100%");
> 
> 
> Regards
> Tonny Kohar


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