RE: [xep-support] Scaling of images

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Wed Oct 17 2007 - 05:04:27 PDT

At 2007-10-17 02:42 -0400, Daragh Pender wrote:
>I seem to have found a solution with:
>
><fo:external-graphic src="url({$href})" content-width="scale-to-fit"
>content-height="100%" width="100%" scaling="uniform"/>
>
>it is very particular about quotes and/or double-quotes !!

I'm not sure what you are referring to when you say "it". There are
rules for XML that have to be followed. I note that you didn't
follow my recommendation for the encoding of the src= attribute and
I'm not sure why.

You changed the reference from @src to $href and it works ... that's
based on stylesheet code that you did not include in your original
post ... but there is one thing remaining that should be left in the
archive for readers to know.

Changing the reference to the new one you've used, I suggested in my
earlier post that you use:

     src='url("{$href}")'

IETF RFC 2396 specifically allows left and right parentheses and
single quotes in URI strings. As a stylesheet writer one does not
have control over the URI strings that are being written by the
authors of the XML. Therefore stylesheet writers have to protect
their stylesheets from "breaking" when their users use an arbitrary
URI sequence.

So, I tell my students the safest way to write the stylesheet is to
enclose the URI in double quotes because a double quote is not
allowed in URI syntax according to IETF RFC 2396. By using double
quotes, there is no way the stylesheet will choke on a valid URI
string written by the XML author.

Given that the attribute has to contain double quotes, there are two
ways this can be specified in XML. The easiest is above, where the
attribute delimiters are single quotes.

If you feel compelled to use double quotes for your attribute
delimiters (and there are some who do and don't like using single
quote delimiters), then you need to escape the double quotes that
I've shown above are essential to protect your stylesheet:

    src="url(&quot;{$href}&quot;)"

I think this is a good example of why on the XML committee it was
decided to build in the &quot; and &apos; entity references for
well-formed files.

>...there is probably a better way of implementing this -

I had suggested one, yes. I think readers of the archive should know
that the one I suggested is safer than the one you used.

>but I can find very little instruction available on the web.

Which parts were you missing? When you tried "@src" and it didn't
work, but "$href" did work, I don't think there is anything that
would have helped ... that decision is based on the structure of your
input XML vocabulary and your stylesheet use of variables.

I hope this helps! (And I'm trying very careful not to be accused of
being grumpy again ... was I gentle enough? I'm only trying to
ensure the long-term archive accurately reflects what stylesheet
writers need to know)

. . . . . . . . . . . . Ken

--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/f/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Jul'07  http://www.CraneSoftwrights.com/f/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html
Received on Wed Oct 17 05:41:59 2007

This archive was generated by hypermail 2.1.8 : Wed Oct 17 2007 - 05:42:05 PDT