How to use catalog.xml in document() function

Jack Bush
  • Jack Bush
    Jack Bush

    Hi Forum members,

    I am encountering an issue in Saxon 9.1 XSLT 2.0 stylesheet when trying to
    open secondary xhtml documents (using document() function) generated from
    TagSoup parser which included the following DTD entity reference:

    The data that I need is in the xhtml document already and the lookup of DTD
    has been more of a nuisance in this case. As a result, I am wondering whether
    the following steps could be achieved:

    ( i ) How to direct the document() function in masterdox1.xsl stylesheet to
    use catalog.xml to lookup local a copy of DTD instead.

    Please refer to the original issue
    which has been partly
    resolved using catalog.xml when looking up the main source in Java as follows:

    // Convert State HTML to XML format
    SAXBuilder stateSaxBuilder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser",
    org.jdom.Document xhtmlmainjdomDocument =;

    Transformer transformer = TransformerFactory.newTransformer(new

    JDOMSource source = new JDOMSource(xhtmlmainjdomDocument);
    JDOMResult result = new JDOMResult();

    transformer.transform(source, result); // breaks on line 17 below in
    masterdox1.xsl when trying to read additional xhtml docs

    The snippet of masterdox1.xsl is as follows:

    8 <xsl:template match="/">
    9 <html>
    10 <head>
    11 <xsl:value-of select="/report/title"/>
    12 </head>
    13 <body style="font-family: sans-serif;">

    Selected Purchase Orders - Unsorted

    15 <xsl:for-each select="/report/po">
    16 <xsl:apply-templates<br>17 select="**document(@filename)/purchase-order**"/>
    18 </xsl:for-each>
    19 </body>
    20 </html>
    21 </xsl:template>

    Any assistance would be much appreciated.



  • Michael Kay
    Michael Kay

    The basic answer is here:

    except that it's written in terms of using the command line rather than the
    JAXP API. It describes it like this:

    Similarly, Saxon supports command-line access to the resolvers:

    The -x class is used to read source documents, the -y class is used to read

    The one that's important in your case (resolving the reference to a DTD held
    in the source document) is the -x option, which selects an XML parser
    preconfigured to use an EntityResolver that uses the catalog. The equivalent
    option using the JAXP API is


  • Jack Bush
    Jack Bush

    Hi Michael,

    Yes, perfect! Everything is working at last.
    Word cannot explain how elated I feel finally after beating around the bush
    for so long.

    This couldn't have been achieved without your help.

    Thank you very much once again,