Forum How do I...?

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

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,

- with,

$ prince --baseurl index.html

- then the <a href=".."> correctly links to and the stylesheet, <link href="../index.css" rel="stylesheet" type="text/css"/>, is found at, so the background is red

The root element of the input document has an xml:base="" attribute, and when I process it without the --baseurl command line option the <a href=".."> still correctly links to, but the stylesheet isn't found so the background isn't white,

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?
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.
In Prince 8.0 the xml:base attribute should now correctly apply to the XHTML link and style elements.