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 Daling Xu <da...@yahoo.com> on 2007/11/30 19:00:40 UTC
anything wrong with this XSL snippet
Hi,
I am using FOP to generate PDF from an XML doc.
In my PDF, I would like to insert image in some places, but because not every time I have an image for all the element in the xml, I use a XSL:If statement like this way:
<fo:block >
<xsl:if test="@statusImageURL"><fo:external-graphic src="{@statusImageURL}"/></xsl:if>
<xsl:value-of select="@status"/>
</fo:block>
My XML element looks like:
<ElementName statusImageURL="urlxyz" status="mystatusString" />
Here the 'statusImageURL' is an optional attr, my intention is that if an element has a statusImageURL attr, the fo generated should be:
<fo:block><fo:external-graphic src="My URL XYZ"/>myStatusString123</fo:block>
But for an XML element without a statusImageURL, the fo should be:
<fo:block>myStatusString123</fo:block>
But in my actual case, the system always generate something like
<fo:block><fo:external-graphic src=""/>myStatusString123</fo:block>
even my xml doesn't have the 'statusImageURL' attr, and this finally cause FOP an exception of
Error while recovering image information () : null
org.apache.fop.fo.flow.ExternalGraphic bind
SEVERE: Image not available:
Any idea what's wrong with my XSLT?
Thanks
Linda
---------------------------------
Get easy, one-click access to your favorites. Make Yahoo! your homepage.
Re: anything wrong with this XSL snippet
Posted by Jay Bryant <ja...@bryantcs.com>.
I don't see a problem with what you've shown here. Can you send the actual
XSLT code (and a chunk of the XML input) that you use?
Jay Bryant
Bryant Communication Services
http://www.bryantcs.com/
----- Original Message -----
From: "Daling Xu" <da...@yahoo.com>
To: <fo...@xmlgraphics.apache.org>
Sent: Friday, November 30, 2007 12:00 PM
Subject: anything wrong with this XSL snippet
> Hi,
>
> I am using FOP to generate PDF from an XML doc.
>
> In my PDF, I would like to insert image in some places, but because not
> every time I have an image for all the element in the xml, I use a XSL:If
> statement like this way:
> <fo:block >
> <xsl:if test="@statusImageURL"><fo:external-graphic
> src="{@statusImageURL}"/></xsl:if>
> <xsl:value-of select="@status"/>
> </fo:block>
>
> My XML element looks like:
> <ElementName statusImageURL="urlxyz" status="mystatusString" />
> Here the 'statusImageURL' is an optional attr, my intention is that if
> an element has a statusImageURL attr, the fo generated should be:
>
> <fo:block><fo:external-graphic src="My URL
> XYZ"/>myStatusString123</fo:block>
>
> But for an XML element without a statusImageURL, the fo should be:
> <fo:block>myStatusString123</fo:block>
>
> But in my actual case, the system always generate something like
> <fo:block><fo:external-graphic src=""/>myStatusString123</fo:block>
> even my xml doesn't have the 'statusImageURL' attr, and this finally
> cause FOP an exception of
> Error while recovering image information () : null
>
> org.apache.fop.fo.flow.ExternalGraphic bind
> SEVERE: Image not available:
>
> Any idea what's wrong with my XSLT?
>
> Thanks
>
> Linda
>
>
> ---------------------------------
> Get easy, one-click access to your favorites. Make Yahoo! your homepage.
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
Re: anything wrong with this XSL snippet
Posted by Andreas L Delmelle <a_...@pandora.be>.
On Nov 30, 2007, at 19:00, Daling Xu wrote:
Hi
> I am using FOP to generate PDF from an XML doc.
>
> In my PDF, I would like to insert image in some places, but because
> not every time I have an image for all the element in the xml, I
> use a XSL:If statement like this way:
> <fo:block >
> <xsl:if test="@statusImageURL"><fo:external-graphic
> src="{@statusImageURL}"/></xsl:if>
> <xsl:value-of select="@status"/>
> </fo:block>
> <snip />
> Any idea what's wrong with my XSLT?
Nothing inherently wrong about it. Are you *absolutely* certain the
source does *not* contain the attribute (not even an empty one)?
Another (very remote) possibility:
Does the source XML contain a reference to a DTD, perhaps?
Not 100% certain, but I seem to remember having seen this once: an
empty attribute being added due to DTD validation.
If the attribute is not defined as #IMPLIED, but with a default value
of "" (empty string), then it could be added by the XML parser, so we
wouldn't see it in the source, but the XSLT processor would.
HTH!
Cheers
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org