Search code examples
xmlxsltprincexml

Why styles don't apply to xml inside princexml


I have some XML:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="./example.xsl"?>
<article>
    <title>Some title</title>
    <author>Some Author</author>
</article>

and XSL:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/2001/XMLSchema-instance">
  <xsl:output method="html" />

  <xsl:template match="/">
    <h1>
      <xsl:value-of select="//title"/>
    </h1>
    <h2>
      <xsl:value-of select="//author"/>
    </h2>
  </xsl:template>
</xsl:stylesheet>

When I am running this on the browser I have this: enter image description here

But I need to generate PDF from this XML, therefore I should use princexml, when I am running prince ./examples/example.xml generate pdf with this content: enter image description here Why styles does not apply to xml inside princexml?


Solution

  • Prince does not support XSL, it supports CSS. Please use an XSLT processor to convert the XML first, then pass the result to Prince.