I’ve encountered a problem using xslt:transform in to transform some old XML that contains a DTD DOCTYPE system literal pointing to a non-working URI and also uses ENTITYREF attributes to refer to image files. I have the XML Catalog configured correctly using CATFILE. The XSLT is using unparsed-entity-uri() to convert the ENTITYREF into a file name for an href attribute. I’ve tested the XSLT and the XML Catalog in oXygen and in XSpec, so I know they work. I’ve tried a few alternatives to get this to work in BaseX and have not arrived at a working solution.

 

The BaseX setup uses BaseX 9.3.3, XML Resolver 1.2, and Saxon HE 9.9.1-7.

 

Passing the XML directly to xslt:transform does not use the XML Catalog for parsing the XM. I’ve tried making the first parameter of xslt:transform a path to a XML file, an xs:anyURI pointing to the XML file, or string containing the XML. Each time the XML fails to parse due to the non-working URI in the system literal. When I change the system literal to a URI that works the transformation works and the unparsed-entity-uri() function produces the expected file name for the href attribute.

 

I also tried parsing the XML using doc() or fetch:xml() first and then using the parsed XML as the first parameter of xslt:transform(). The doc() or fetch:xml does use the XML Catalog to parse the XML. However, unparsed-entity-uri() function produces an empty string because the DTD information is no longer available.

 

Hoping to be able to spot the problem I looked through the BaseX code. XsltTransform is using CatalogWrapper to set a URIResolver, but is not setting an EntityResolver. SAXWrapper is using CatalogWrapper to set an EntityResolver before parsing XML. It looks like this should work, but it’s not.

 

The next alternative is to pre-process the XML using a regular expression to replace the non-working URI in the DOCTYPE system literal with a working URI prior to xslt:transform(). This works, but it seems like this is just working around a problem.

 

Has anyone else encountered this problem and found a better solution?

 

Thanks,

Vincent

 

______________________________________________

Vincent M. Lizzi

Head of Information Standards | Taylor & Francis Group

530 Walnut St., Suite 850, Philadelphia, PA 19106

E-Mail: vincent.lizzi@taylorandfrancis.com

Phone: 215-606-4221

Web: www.tandfonline.com

 

Taylor & Francis is a trading name of Informa UK Limited,

registered in England under no. 1072954

 

"Everything should be made as simple as possible, but not simpler."

 


Information Classification: General