You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jeremy Nix <Je...@sfsltd.com> on 2003/05/21 18:02:20 UTC
External graphic referencing within a servlet
I'm using a serlvet to perform the XSLT transformation into my PDF
document. Everything works fine EXCEPT the images. I've tried
referencing my images many different ways, and none seem to work. Does
anybody know how to get this functionality to work?
Here's my graphic:
<fo:external-graphic text-align="center" height="40px" width="76.31px"
src="file:url(logo.gif)"/>
Webapp structure:
/WEBAPP_NAME/xsl/doc.xsl
/WEBAPP_NAME/xsl/logo.gif
Environment:
-Tomcat 4.1.24
-Windows XP box
-Fop-0.20.5rc3
-JDK 1.4.1_02
_________________
Jeremy Nix
Senior Application Developer
Southwest Financial Ltd.
Jeremy.Nix@sfsltd.com
(513) 621-6699 ext 1158
RE: External graphic referencing within a servlet
Posted by Victor Mote <vi...@outfitr.com>.
Clay Leeds wrote (a long time ago, May 21, 2003 to be exact):
> On 5/21/2003 9:18 AM, Jeremias Maerki wrote:
> > You may need to the the base directory/URL. See:
> > http://xml.apache.org/fop/embedding.html#config-internal
> >
> > But I think your src attribute is wrong. It should be something like
> > this: src="url(file:logo.gif)".
>
> I was thinking it was this:
>
> <fo:external-graphic text-align="center" height="40px" width="76.31px"
> src="url(logo.gif)"/>
>
> or if it were in sub-directory "images/" it would look like this:
>
> <fo:external-graphic text-align="center" height="40px" width="76.31px"
> src="url(images/logo.gif)"/>
>
> Yup! 'Just looked, and that's how it's written on page 93 of Dave
> Pawson's O'Reilly book "XSL-FO: Making XML Look Good in Print".
First, again I apologize for being so slow. I am cleaning out old items that
I had marked for followup.
You are both right. Jeremias has included the URI scheme to be more
explicit. The URI you reference is relative to the base URI.
> BTW, Page 652 of Elliotte Rusty Harold's XML Bible indicates it should
> be written like as follows:
>
> <fo:external-graphic src="images/logo.jpg"/>
>
> <fo:external-graphic src="http://www.medata.com/images/logo.jpg"/>
>
> ...hmmm...
Probably based on a pre-release version of the spec. Pawson's book indicates
that there was some controversy about whether to use URIs.
> I just checked the spec:
>
> fo:external-graphic
> http://www.w3.org/TR/2001/REC-xsl-20011015/slice6.html#fo_external-graphic
>
> src
> http://www.w3.org/TR/2001/REC-xsl-20011015/slice7.html#src
>
> and they didn't have an example (D'oh!, why don't they give examples!?)
The URI spec is pretty flexible, and documenting a useful range of examples
would be a big job, and no doubt considered outside the scope of the spec,
which is after all a spec, not a tuturial, and certainly not a tutorial on
URI. What *is* there is a definition of the uri-specification datatype,
including a reference to the URI spec itself:
http://www.w3.org/TR/2001/REC-xsl-20011015/slice5.html#section-N8794-Propert
y-Datatypes
(Yes, it would have been helpful for them to link from the "src" definition
to the datatype definition).
> I also looked at zvon.org, and they show it as:
> <fo:external-graphic src="file:../graphics/images/logo.jpg"/>
Just missing the url() syntax. Again, perhaps an old version of the spec.
> NOTE-TO-VICTOR: Once we get this completely straightened out, this info
> might be useful at the top of the graphics page, to help newbies craft
> this little call (although we could also include the plethora of
> whichever functioning options will work). I use the following (works
> perfectly), so we might just want to use it as our example:
>
> <fo:external-graphic src="url('images/logo.jpg')" width="1.87cm"
> height=".99cm" content-width="1.87cm" content-height=".99cm" border="0"/>
OK, I have added a section to our XSL-FO page which documents how to
reference "External Resources", esp. those on local filesystems, and I have
updated our FAQ page to point to this. Since this is *strictly* an XSL-FO
issue, and since it can be found through the FAQ already, I'm going to keep
it off of our Graphics page, although we can add a link from there to the
"External Resources" doc later if it looks like it is needed.
These changes are in CVS, & will be published in the next week or so.
Victor Mote
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: External graphic referencing within a servlet
Posted by Clay Leeds <cl...@medata.com>.
On 5/21/2003 9:18 AM, Jeremias Maerki wrote:
> You may need to the the base directory/URL. See:
> http://xml.apache.org/fop/embedding.html#config-internal
>
> But I think your src attribute is wrong. It should be something like
> this: src="url(file:logo.gif)".
I was thinking it was this:
<fo:external-graphic text-align="center" height="40px" width="76.31px"
src="url(logo.gif)"/>
or if it were in sub-directory "images/" it would look like this:
<fo:external-graphic text-align="center" height="40px" width="76.31px"
src="url(images/logo.gif)"/>
Yup! 'Just looked, and that's how it's written on page 93 of Dave
Pawson's O'Reilly book "XSL-FO: Making XML Look Good in Print".
BTW, Page 652 of Elliotte Rusty Harold's XML Bible indicates it should
be written like as follows:
<fo:external-graphic src="images/logo.jpg"/>
<fo:external-graphic src="http://www.medata.com/images/logo.jpg"/>
...hmmm...
I just checked the spec:
fo:external-graphic
http://www.w3.org/TR/2001/REC-xsl-20011015/slice6.html#fo_external-graphic
src
http://www.w3.org/TR/2001/REC-xsl-20011015/slice7.html#src
and they didn't have an example (D'oh!, why don't they give examples!?)
I also looked at zvon.org, and they show it as:
<fo:external-graphic src="file:../graphics/images/logo.jpg"/>
NOTE-TO-VICTOR: Once we get this completely straightened out, this info
might be useful at the top of the graphics page, to help newbies craft
this little call (although we could also include the plethora of
whichever functioning options will work). I use the following (works
perfectly), so we might just want to use it as our example:
<fo:external-graphic src="url('images/logo.jpg')" width="1.87cm"
height=".99cm" content-width="1.87cm" content-height=".99cm" border="0"/>
(NOTE: shown actual size & pulled directly from functioning code)
(NOTE: no animals were harmed in the execution of this code)
--
Clay Leeds - cleeds@medata.com
Web Developer - Medata, Inc. - http://www.medata.com
PGP Public Key: https://mail.medata.com/pgp/cleeds.asc
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: External graphic referencing within a servlet
Posted by Jeremias Maerki <de...@greenmail.ch>.
You may need to the the base directory/URL. See:
http://xml.apache.org/fop/embedding.html#config-internal
But I think your src attribute is wrong. It should be something like
this: src="url(file:logo.gif)".
On 21.05.2003 18:02:20 Jeremy Nix wrote:
> I'm using a serlvet to perform the XSLT transformation into my PDF
> document. Everything works fine EXCEPT the images. I've tried
> referencing my images many different ways, and none seem to work. Does
> anybody know how to get this functionality to work?
>
> Here's my graphic:
> <fo:external-graphic text-align="center" height="40px" width="76.31px"
> src="file:url(logo.gif)"/>
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: External graphic referencing within a servlet
Posted by "J.Pietschmann" <j3...@yahoo.de>.
William Gilbert wrote:
>>src="file:url(logo.gif)"/>
That's not a meaningful value, it will be interpreted as a file
ULR pointing to the file named "url(logo.gif)", and it's also
violating URI syntax. Use
src="url(logo.gif)"
instead and set the baseURL configuration value.
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: External graphic referencing within a servlet
Posted by William Gilbert <Gi...@Informagen.com>.
> I'm using a serlvet to perform the XSLT transformation into my PDF document.
> Everything works fine EXCEPT the images. I've tried referencing my images
> many different ways, and none seem to work. Does anybody know how to get this
> functionality to work?
>
> Here's my graphic:
> <fo:external-graphic text-align="center" height="40px" width="76.31px"
> src="file:url(logo.gif)"/>
>
I've run into this with other external files. I *think* that the servlet
don't have a notion of a local working directory.
In my web.xml config file I pass locations into the servlet and store them
as globals
<servlet>
<servlet-name>ReportServlet</servlet-name>
<description/>
<servlet-class>com.hgsi.servlet.ReportServlet</servlet-class>
<init-param>
<param-name>assemblyPath</param-name>
<param-value>
/Library/Tomcat/webapps/CoGenesys/Assembly
</param-value>
</init-param>
</servlet>
In the servlet I use a global
static String assemblyPath = null;
and load it in the init() method
assemblyPath = config.getInitParameter("assemblyPath");
if (assemblyPath == null)
throw new ServletException("Parameter 'assemblyPath' not
specified in web.xml");
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org