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 "William L. Gibson" <gi...@lanl.gov> on 2003/08/21 19:59:42 UTC

How to use a calculated url?

Hi,

I wish to use fop-0.20.5rc3 to process an XML doc using an XSL
stylesheet that contains both XSLT and FO directives. I extract an
itemNumber from the XML, save it in an XSL variable, use it to
dynamically build a url to an external servlet that will return a jpeg
barcode for that item number. I store the calculated url in an XSL
variable. Finally I wish to use the FO external-graphic to place the
servlet generated image into the output pdf document, but I can't figure
out any way to put the calculated url into the src attribute. It seems
to only accept a string literal.

Is there any way to do what I want (use a calculated url to insert an
image generated by an external servlet)?

<xsl:variable name="itemNumber"
select="ReportData/Record/structItemRecord/core/structItem/strItemNumber"/>

<xsl:variable name="calcUrl"
select="concat('http://www.javabarcoding.com/servlet/lin?BARCODE=',
$itemNumber,
'&amp;BAR_HEIGHT=1&amp;CODE_TYPE=CODE39&amp;X=0.03&amp;CHECK_CHAR=N&amp;CHECK_CHARINTEXT=N&amp;CODE128_SET=0&amp;HEIGHT=100&amp;WIDTH=400')"/>

<fo:block text-align="left"><fo:external-graphic
src="url(????????)"/></fo:block>

By the way, the url function that is shown in some fop examples used
inside the src attribute as above must be a fop specific function or so
it seems to me. Where can I find documentation on such fop functions?



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


Re: How to use a calculated url?

Posted by "William L. Gibson" <gi...@lanl.gov>.
Thank you very much Victor (Mote) for your prompt answer. You solution was
exactly what I needed. I did not realize it was an XSLT question until I saw
your answer. Thanks for getting me un-stuck!

Victor Mote wrote:

> William L. Gibson wrote:
>
> > I wish to use fop-0.20.5rc3 to process an XML doc using an XSL
> > stylesheet that contains both XSLT and FO directives. I extract an
> > itemNumber from the XML, save it in an XSL variable, use it to
> > dynamically build a url to an external servlet that will return a jpeg
> > barcode for that item number. I store the calculated url in an XSL
> > variable. Finally I wish to use the FO external-graphic to place the
> > servlet generated image into the output pdf document, but I can't figure
> > out any way to put the calculated url into the src attribute. It seems
> > to only accept a string literal.
> >
> > Is there any way to do what I want (use a calculated url to insert an
> > image generated by an external servlet)?
> >
> > <xsl:variable name="itemNumber"
> > select="ReportData/Record/structItemRecord/core/structItem/strItem
> > Number"/>
> >
> > <xsl:variable name="calcUrl"
> > select="concat('http://www.javabarcoding.com/servlet/lin?BARCODE=',
> > $itemNumber,
> > '&amp;BAR_HEIGHT=1&amp;CODE_TYPE=CODE39&amp;X=0.03&amp;CHECK_CHAR=
> N&amp;CHECK_CHARINTEXT=N&amp;CODE128_SET=0>
> &amp;HEIGHT=100&amp;WIDTH=400')"/>
> >
> > <fo:block text-align="left"><fo:external-graphic
> > src="url(????????)"/></fo:block>
>
> I'm not sure I'm following your question. Are you trying to do this?:
>
>     <fo:block text-align="left>
>       <fo:external-graphic>
>         <xsl:attribute name="src">
>           <xsl:value-of select="$calcUrl"/>
>         </xsl:attribute>
>       </fo:external-graphic>
>           ....
>
> I'm not really fluent in XSLT, but the above seems to be the concept you are
> looking for. The syntax may need some work.
>
> BTW, pure XSLT questions like this kind of risk getting ignored on this
> list. See:
> http://xml.apache.org/fop/maillist.html#fop-user-policy
> for more information, and see:
> http://xml.apache.org/fop/maillist.html#xslt-mulberry
> for an XSLT-specific mailing list. And see:
> http://xml.apache.org/fop/resources.html#documents-xslt
> for a list of XSLT books and other resources that you may find helpful.
>
> > By the way, the url function that is shown in some fop examples used
> > inside the src attribute as above must be a fop specific function or so
> > it seems to me. Where can I find documentation on such fop functions?
>
> See:
> http://xml.apache.org/fop/fo.html#external-resources
> where the syntax is described, with links to the appropriate underlying
> standards. It is possible that some of the example files are not up-to-date.
> If you can be more specific, we'll work on getting them fixed.
>
> Victor Mote
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: fop-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org


RE: How to use a calculated url?

Posted by Victor Mote <vi...@outfitr.com>.
William L. Gibson wrote:

> I wish to use fop-0.20.5rc3 to process an XML doc using an XSL
> stylesheet that contains both XSLT and FO directives. I extract an
> itemNumber from the XML, save it in an XSL variable, use it to
> dynamically build a url to an external servlet that will return a jpeg
> barcode for that item number. I store the calculated url in an XSL
> variable. Finally I wish to use the FO external-graphic to place the
> servlet generated image into the output pdf document, but I can't figure
> out any way to put the calculated url into the src attribute. It seems
> to only accept a string literal.
>
> Is there any way to do what I want (use a calculated url to insert an
> image generated by an external servlet)?
>
> <xsl:variable name="itemNumber"
> select="ReportData/Record/structItemRecord/core/structItem/strItem
> Number"/>
>
> <xsl:variable name="calcUrl"
> select="concat('http://www.javabarcoding.com/servlet/lin?BARCODE=',
> $itemNumber,
> '&amp;BAR_HEIGHT=1&amp;CODE_TYPE=CODE39&amp;X=0.03&amp;CHECK_CHAR=
N&amp;CHECK_CHARINTEXT=N&amp;CODE128_SET=0>
&amp;HEIGHT=100&amp;WIDTH=400')"/>
>
> <fo:block text-align="left"><fo:external-graphic
> src="url(????????)"/></fo:block>

I'm not sure I'm following your question. Are you trying to do this?:

    <fo:block text-align="left>
      <fo:external-graphic>
        <xsl:attribute name="src">
          <xsl:value-of select="$calcUrl"/>
        </xsl:attribute>
      </fo:external-graphic>
          ....

I'm not really fluent in XSLT, but the above seems to be the concept you are
looking for. The syntax may need some work.

BTW, pure XSLT questions like this kind of risk getting ignored on this
list. See:
http://xml.apache.org/fop/maillist.html#fop-user-policy
for more information, and see:
http://xml.apache.org/fop/maillist.html#xslt-mulberry
for an XSLT-specific mailing list. And see:
http://xml.apache.org/fop/resources.html#documents-xslt
for a list of XSLT books and other resources that you may find helpful.

> By the way, the url function that is shown in some fop examples used
> inside the src attribute as above must be a fop specific function or so
> it seems to me. Where can I find documentation on such fop functions?

See:
http://xml.apache.org/fop/fo.html#external-resources
where the syntax is described, with links to the appropriate underlying
standards. It is possible that some of the example files are not up-to-date.
If you can be more specific, we'll work on getting them fixed.

Victor Mote


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org