Project

Profile

Help

Bug #4274

closed

Using a catalog file with Saxon in PHP

Added by Alf Eaton over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Low
Category:
Saxon-C Internals
Start date:
2019-08-10
Due date:
% Done:

100%

Estimated time:
Found in version:
1.1.2
Fixed in version:
1.2.0
Platforms:

Description

I'm using the Saxon/C PHP extension, v1.1.2, and I'd like to be able to use a catalog file for DTD resolution.

If the following worked I'd be able to either edit /etc/xml/catalog or edit CatalogManager.properties to point to a different catalog file, but I can only get a "Cannot find CatalogManager.properties" error:

    $saxonProcessor = new Saxon\SaxonProcessor();

    // use resolver.jar
    $saxonProcessor->setConfigurationProperty('http://saxon.sf.net/feature/sourceParserClass', 'org.apache.xml.resolver.tools.ResolvingXMLReader');

    $processor = $saxonProcessor->newXsltProcessor();
    $processor->setSourceFromFile('input.xml');
    $processor->compileFromFile('example.xsl');
    $result = $processor->transformToString();

As the CLASSPATH environment variable doesn't seem to be relevant in this situation, where is the resolver looking for CatalogManager.properties?


Files

SaxonProcessor.h (17.5 KB) SaxonProcessor.h O'Neil Delpratt, 2019-08-14 00:15
php_saxon.h (9.81 KB) php_saxon.h O'Neil Delpratt, 2019-08-14 00:15
SaxonProcessor.cpp (23 KB) SaxonProcessor.cpp O'Neil Delpratt, 2019-08-14 00:15
php7_saxon.cpp (120 KB) php7_saxon.cpp O'Neil Delpratt, 2019-08-14 00:15
Actions #1

Updated by Michael Kay over 4 years ago

  • Project changed from Saxon to SaxonC
  • Category set to PHP Build
  • Assignee set to O'Neil Delpratt
Actions #4

Updated by O'Neil Delpratt over 4 years ago

  • Status changed from New to In Progress
  • Found in version set to 1.1.2

Thanks for reporting this issue. All the right classes are packaged within Saxon/C for using a catalog file, but don't think it will work directly using the API. I am investigating it further for a workaround or what we can add in the API.

Actions #5

Updated by O'Neil Delpratt over 4 years ago

  • Tracker changed from Support to Bug

To support catalog files in Saxon/C PHP it will require some addition code in the C++ API, which will in turn work for the PHP API...

We need to do the equivalent in C++ using JNI for the following Java code:

String catalog = "/Applications/oxygen-2/frameworks/dita/catalog.xml";
XmlCatalogResolver.setCatalog(catalog, proc.getUnderlyingConfiguration(), true);

I am marking this as a bug issue. Is this something that can be fixed for the next release or is it need more urgently? In which case I could put together a patch in the C++ and PHP code.

Actions #6

Updated by Alf Eaton over 4 years ago

Thanks for investigating this issue - if there's a release planned for the next couple of weeks that would be fine, otherwise a patch would be great.

Actions #7

Updated by O'Neil Delpratt over 4 years ago

Hi,

I have managed to get the catalog feature working within Saxon/C for C++ and PHP. We cannot promise a new release will be out in the next few weeks. But we can provide you with some patched files which will allow you to use the catalog files.

Therefore please replace the following files (SaxonProcessor.h, SaxonProcessor.cpp, php_saxon.h and php7_saxon.cpp) with these new copies attached to this bug issue. I suggest backing up the files before you replace them too.

See PHP example below of using a catalog file (I have assumed you are using PHP7).

   <body>
        <?php 
           $saxonProcessor = new Saxon\SaxonProcessor();
           $processor = $saxonProcessor->newXsltProcessor();

           $isTracing = false;
    
           $saxonProcessor->setCatalog("/dir/samples/php/catalog-test/catalog.xml", $isTracing); 
   
           $processor->setSourceFromFile('/dir/samples/php/catalog-test/example.xml');
           $processor->compileFromFile('/dir/samples/php/catalog-test/test1.xsl');
           $result = $processor->transformToString();
      ?>
</body>
Actions #8

Updated by Alf Eaton over 4 years ago

I can confirm that the patched files worked perfectly - many thanks for finding a quick solution to this issue.

Actions #9

Updated by O'Neil Delpratt over 4 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 1.2.0

Big fix applied in the Saxon/C 1.2.0 release.

Please register to edit this issue

Also available in: Atom PDF