Project

Profile

Help

How to use catalog.xml in document() function

Added by Anonymous almost 14 years ago

Legacy ID: #8529195 Legacy Poster: Jack Bush (netbeansfan)

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 [url=null]http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201007/msg00094.html [/url]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", false); org.jdom.Document xhtmlmainjdomDocument = saxBuilder.build(originalHTMLFILE); ..... Transformer transformer = TransformerFactory.newTransformer(new StreamSource(masterdox1.xsl)); 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 10

11 <title><xsl:value-of select="/report/title"/></title> 12 13 14

Selected Purchase Orders - Unsorted

15 <xsl:for-each select="/report/po"> 16 <xsl:apply-templates 17 select="[b]document(@filename)/purchase-order[/b]"/> 18 </xsl:for-each> 19 20 21 </xsl:template> .... Any assistance would be much appreciated. Thanks, Jack

Replies (2)

RE: How to use catalog.xml in document() function - Added by Anonymous almost 14 years ago

Legacy ID: #8529799 Legacy Poster: Michael Kay (mhkay)

The basic answer is here: http://xml.apache.org/commons/components/resolver/resolver-article.html 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: -x org.apache.xml.resolver.tools.ResolvingXMLReader -y org.apache.xml.resolver.tools.ResolvingXMLReader -r org.apache.xml.resolver.tools.CatalogResolver The -x class is used to read source documents, the -y class is used to read stylesheets. 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 factory.setAttribute("http://saxon.sf.net/feature/sourceParserClass", "org.apache.xml.resolver.tools.ResolvingXMLReader")

RE: How to use catalog.xml in document() function - Added by Anonymous almost 14 years ago

Legacy ID: #8529945 Legacy Poster: Jack Bush (netbeansfan)

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, Jack

    (1-2/2)

    Please register to reply