Re: [xsl] fo basic link question

Subject: Re: [xsl] fo basic link question
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Nov 2009 23:03:52 -0500
At 2009-11-10 19:12 -0800, Mark Wilson wrote:
Every example for building a uri("...") I can find always fills the parentheses with a quoted string, like uri("s.pdf"). I want to use the value of an attribute:

<fo:basic-link external-destination="url(Heading/@file)" color="blue">

Can I do that? If so, how?

Using an attribute value template:


<fo:basic-link external-destination='url("{Heading/@file}")' color="blue">

I tell my students it is safest to use double quotes inside the url() syntax:

url(".....uri.....")

... because URI syntax in RFC2141 section 2.2 production <other> allows each of "(", ")" and "'" in a URI, but it doesn't allow a double quote. So imagine that you have used either of the other combinations the specification allows:

   url('......uri.....')
   url(.......uri......)

... and your users end up creating a URI that contains "'" or ")" (respectively). You don't know the syntax they are using, you are just plugging it into the result using XSLT. The resulting XSL-FO has a malformed specification because the URI string is prematurely terminated.

And don't forget about your attribute delimiters. If you want to use double quotes as your attribute delimiter, you'll need to escape the double quote inside. In my example above I've used single quotes for the attribute delimiters which allows me to use naked double quotes inside.

This happened to be part of today's lecture as I am teaching XSL-FO this week in Washington DC.

I hope this helps.

. . . . . . . . . . Ken



--
Upcoming:  hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009
Interested in other classes?  http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread