genkgo / xsl

XSL 2.0 Transpiler in PHP
MIT License
51 stars 7 forks source link

XSLT/SCH files #37

Closed AurelienPillevesse closed 11 months ago

AurelienPillevesse commented 1 year ago

Currently, I'm looking to use this library if my use-case is covered by this one.

I explain : To validate an e-invoicing (electronic invoice), I have to execute a Schematron on the XML file.

I have this .xslt file : https://github.com/ConnectingEurope/eInvoicing-EN16931/blob/master/cii/xslt/EN16931-CII-validation.xslt I have this .sch file : https://github.com/ConnectingEurope/eInvoicing-EN16931/blob/master/cii/schematron/EN16931-CII-validation.sch

If someone can help me but it's the first time I'm working with Schematron. I would like to get all errors from my XML after validation with the XSLT/SCH file.

The only feedback I have for the moment : Genkgo\Xsl\Exception\TransformationException: Transformation failed: XSLTProcessor::importStylesheet(): Invalid expression

And my code :

$xml is a \DOMDocument

$xsl = new \DOMDocument();
$xsl->loadXML((string) file_get_contents(self::SPECIFICATION_TO_SCHEMATRON[$specificationIdentifier]));
$transpiler = new XsltProcessor(new NullCache());
$transpiler->registerPHPFunctions();
$transpiler->importStylesheet($xsl);
$transpiler->transformToXML($xml);
frederikbosch commented 1 year ago

I have no idea to be honest. I have never worked with Schematron. The error feedback you get from this package is not very good. So I cannot help you right now. If you succeed I am interested to know.

LeonardusSagittarius commented 1 year ago

I am also trying to implement a Schematron validation, but don't get it to work.

xslt file: https://github.com/schxslt/schxslt/blob/master/core/src/main/resources/xslt/2.0/pipeline-for-svrl.xsl sch file: https://github.com/w3c/epubcheck/blob/main/src/main/resources/com/adobe/epubcheck/schema/30/package-30.sch

I am getting this Exception: Transformation failed: Transformation failed: XSLTProcessor::importStylesheet(): compilation error: file gxsl://localhost/[...]/svrl.xsl line 11 element sequence

The problem is obviously caused by the included file: https://github.com/schxslt/schxslt/blob/master/core/src/main/resources/xslt/2.0/svrl.xsl

My code looks like this:

`$pipeline_for_svrl = new \DOMDocument(); $pipeline_for_svrl->load( Schematron::XSLT_PATH . '2.0/pipeline-for-svrl.xsl' );

$schema = new \DOMDocument(); $schema->load( $schema_path );

$xslt = new XsltProcessor( new NullCache() ); $xslt->importStylesheet( $pipeline_for_svrl );

$transformed = $xslt->transformToXML( $schema );`

frederikbosch commented 1 year ago

That's a duplicate of issue #33. We do not have support for yet.