Forum How do I...?

How to get stylesheet URL to resolve against xml:base="..."?

jablko
It's possible to specify the base URL of the input document with either the Prince --baseurl command line option, or an xml:base="..." attribute in the source document

The --baseurl command line option applies to both links like <a href="..."> and to stylesheets like <link href="..." rel="stylesheet" type="text/css"/>

Both the --baseurl command line option and the xml:base="..." attributes apply to links like <a href="...">

- but xml:base="..." attributes don't apply to stylesheets like <link href="..." rel="stylesheet" type="text/css"/>

For example, when I process this input document, http://www.sfu.ca/~jdbates/tmp/css/201002190/

- with,

$ prince --baseurl http://www.sfu.ca/~jdbates/tmp/css/201002190/foo/bar.html index.html

- then the <a href=".."> correctly links to http://www.sf.ca/~jdbates/tmp/css/201002190/ and the stylesheet, <link href="../index.css" rel="stylesheet" type="text/css"/>, is found at http://www.sf.ca/~jdbates/tmp/css/201002190/index.css, so the background is red

The root element of the input document has an xml:base="http://www.sfu.ca/~jdbates/tmp/css/201002190/foo/bar.html" attribute, and when I process it without the --baseurl command line option the <a href=".."> still correctly links to http://www.sf.ca/~jdbates/tmp/css/201002190/, but the stylesheet isn't found so the background isn't white, http://www.sfu.ca/~jdbates/tmp/css/201002190/index.pdf

What am I doing wrong? How can I get stylesheets like <link href="..." rel="stylesheet" type="text/css"/> to resolve against the base URL from an xml:base="..." attribute?
mikeday
Good catch! Currently we are not applying xml:base attributes when processing <link> elements. However, we are applying the HTML <base> element, which you can use in the document head with similar effect.
mikeday
In Prince 8.0 the xml:base attribute should now correctly apply to the XHTML link and style elements.