Project

Profile

Help

Support #2425

closed

Not all xsl output is captured for use in PHP

Added by Brett Merrick over 9 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
High
Category:
PHP API
Start date:
2015-07-25
Due date:
% Done:

0%

Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
0.3.1
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:

Description

We use xsl to validate supplied xml. It outputs useful debugging info when a xml file processed with it fails.

When the attached saxonex.php is run from the cli, the following info is printed to stdout, but it doesn't seem to be able to be captured for use within PHP. I can verify it is not output generated or seen by PHP by wrapping the processor in an ob_start(), ob_end_clean() - the xsl output I require is still displayed, excluding the final line produced by php.

Attached are the files and script I am testing with. The example xml file should fail and produce the following output indicating that the last tag is empty:

# php saxonex.php

				ErrorMessage: Error! Content of element
				ClassParticipation
				//
				Class
				must not be empty. Please contact your software supplier's helpdesk
				with this error message /ErrorMessage: TechnicalErrorMessage:
				Content of element
				ClassParticipation
				//
				Class
				must not be empty. Please contact your software supplier's helpdesk
				with this error message /TechnicalErrorMessage: XPath
				: /SmsStudentMembership/Person[1]/ClassParticipation[8]/Class[2]

Error at xsl:message on line 204 of foo.xsl:
  XTMM9000: Processing terminated by xsl:message at line 204 in foo.xsl
Exception in thread "main" net.sf.saxon.s9api.SaxonApiException: Processing terminated by xsl:message at line 204 in foo.xsl
	at net.sf.saxon.s9api.XsltTransformer.transform(Unknown Source)
	at net.sf.saxon.option.cpp.XsltProcessorForCpp.xsltApplyStylesheet(Unknown Source)
Caused by: net.sf.saxon.expr.instruct.TerminationException: Processing terminated by xsl:message at line 204 in foo.xsl
	at net.sf.saxon.expr.instruct.Message.processLeavingTail(Unknown Source)
	at net.sf.saxon.expr.instruct.Choose.processLeavingTail(Unknown Source)
	at net.sf.saxon.expr.LetExpression.processLeavingTail(Unknown Source)
	at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Unknown Source)
	at net.sf.saxon.trans.Mode.applyTemplates(Unknown Source)
	at net.sf.saxon.Controller.transformDocument(Unknown Source)
	at net.sf.saxon.Controller.transform(Unknown Source)
	... 2 more
Expected error: Code=XTMM9000 Message=Processing terminated by xsl:message at line 204 in foo.xsl

Files

Archive.zip (6.09 KB) Archive.zip sample xml, xsl and php to demonstrate issue Brett Merrick, 2015-07-25 07:36
Actions #1

Updated by O'Neil Delpratt over 9 years ago

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

Hi thanks for reporting the problem you have found. The capture of xsl:message is missing from Saxon/C. There needs to be a message listener interface similar to what is available in Saxon Java and .Net products.

I will add this feature in the next release of Saxon/C.

Actions #2

Updated by O'Neil Delpratt over 9 years ago

  • % Done changed from 0 to 70

Update:

I have added the feature to capture the xsl:message outputs as an XdmValue. The method getXslMessages() returns the XdmValue which is the sequence of XdmNode objects. I have decided to use the property 'm' to switch on this feature, which is consistent with the Java command-line options.

TODO: Add interface to the PHP extension.

This will be available in the next release.

Actions #3

Updated by O'Neil Delpratt almost 9 years ago

  • % Done changed from 70 to 0

My attempt at adding this mechanism is not quite right. The problem is the xsl:messages will only be available at the end of the transformation. There needs to be a way of making them available immediately as to when it is reached in the transformation therefore informing the user as to where it has happened.

There needs to be some event listener on the C/C++ side. Currently investigating how to do this.

Actions #4

Updated by O'Neil Delpratt over 2 years ago

  • Description updated (diff)
  • Status changed from In Progress to Closed

This bug issue has open for a long time, there I am closing it. Furthermore, I believe that this bug issue has been resolved in version 1.2.1 and improved in version 11.1. If you are still experiencing this problem please reopen this bug issue.

Please register to edit this issue

Also available in: Atom PDF