genkgo / xsl Goto Github PK
View Code? Open in Web Editor NEWXSL 2.0 Transpiler in PHP
License: MIT License
XSL 2.0 Transpiler in PHP
License: MIT License
At this moment only attributes with one attribute containing only the curly brace is supported
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);
we are getting null issue below, can you please help us in this
Genkgo\Xsl\Exception\TransformationException: Transformation failed: str_replace(): Argument #3 ($subject) must be of type array|string, null given in Genkgo\Xsl\XsltProcessor->catchLibXmlErrorThrowTransformException() (line 303 of C:\xampp new\htdocs\vendor\genkgo\xsl\src\XsltProcessor.php).
Looking for source with all xsl 2.0 elements.
PHP will crash with xs:date(xpath/to/element)
when that xpath selection leads to a non-existing element.
Source: Saxon
Double slashes is incorrect in PHP, is required for JS RegExp constructor. Probably also caused operators bug.
Hi, I think the library is not compatible with PHP 7.4. It does not work on my machine (tm).
Travis-CI is building PHP 7.4snapshot
but that is not the same as current PHP 7.4.
Just replace on .travis
s/7.4snapshot/7.4/g
I check using a docker debian:bullseye
image to avoid a problem with my machine and it also fail. Didn't use docker php:7.4
image because extensions xsl
and intl
are not installed by default.
Steps I did to reproduce the problem
docker run -it debian:bullseye /bin/bash
apt update
apt install git zip composer php-xsl php-intl
git clone https://github.com/genkgo/xsl.git genkgo-xsl
cd genkgo-xsl
composer install
vendor/bin/phpunit -c phpunit.xml
PHPUnit output:
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.5
Configuration: /home/eclipxe/work/github/eclipxe/genkgo-xsl/phpunit.xml
.....................................................EEE....... 63 / 217 ( 29%)
............................................................... 126 / 217 ( 58%)
............................................................... 189 / 217 ( 87%)
............................ 217 / 217 (100%)
Time: 139 ms, Memory: 8.00 MB
There were 3 errors:
1) Genkgo\Xsl\Unit\XsltProcessorTest::testVersion1
Genkgo\Xsl\Exception\TransformationException: Transformation failed: Transformation failed: XSLTProcessor::importStylesheet(): compilation error: file gxsl://localhost/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Stubs/version-1.0.xsl#root line 4 element template
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:99
/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Unit/XsltProcessorTest.php:46
Caused by
Genkgo\Xsl\Exception\TransformationException: Transformation failed: XSLTProcessor::importStylesheet(): compilation error: file gxsl://localhost/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Stubs/version-1.0.xsl#root line 4 element template
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:82
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:90
/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Unit/XsltProcessorTest.php:46
2) Genkgo\Xsl\Unit\XsltProcessorTest::testVersion2
Genkgo\Xsl\Exception\TransformationException: Transformation failed: Transformation failed: XSLTProcessor::importStylesheet(): compilation error: file gxsl://localhost/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Stubs/version-2.0.xsl#root line 4 element template
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:99
/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Unit/XsltProcessorTest.php:60
Caused by
Genkgo\Xsl\Exception\TransformationException: Transformation failed: XSLTProcessor::importStylesheet(): compilation error: file gxsl://localhost/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Stubs/version-2.0.xsl#root line 4 element template
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:82
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:90
/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Unit/XsltProcessorTest.php:60
3) Genkgo\Xsl\Unit\XsltProcessorTest::testVersion3
Genkgo\Xsl\Exception\TransformationException: Transformation failed: Transformation failed: XSLTProcessor::importStylesheet(): compilation error: file gxsl://localhost/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Stubs/version-3.0.xsl#root line 4 element template
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:99
/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Unit/XsltProcessorTest.php:74
Caused by
Genkgo\Xsl\Exception\TransformationException: Transformation failed: XSLTProcessor::importStylesheet(): compilation error: file gxsl://localhost/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Stubs/version-3.0.xsl#root line 4 element template
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:82
/home/eclipxe/work/github/eclipxe/genkgo-xsl/src/XsltProcessor.php:90
/home/eclipxe/work/github/eclipxe/genkgo-xsl/test/Unit/XsltProcessorTest.php:74
ERRORS!
Tests: 217, Assertions: 315, Errors: 3.
I don't have the underlying understanding about how this library works, so I don't really know why is this happening.
As far I can see, the problem is related to the object returned by XsltProcessor::getTranspiledStyleSheet()
wich is created without any problem and the error occurs when try to send it to parent::importStylesheet
.
Thanks for your great work!
Any thoughts in supporting XSLT 3.0 in the future?
transformation error when using <xsl:sequence select="$data"/>
can u please fix this?
Hi,
I tried to use genkgo to perform an xsl transformation on an xml, but I have this error :
Catchable fatal error: Argument 1 passed to Genkgo\Xsl\Xsl\Functions\CurrentGroup::isForEachGroupElement() must be an instance of DOMNode, null given, called in C:\wamp64\www\portail\V1\php\vendor\genkgo\xsl\src\Xsl\Functions\CurrentGroup.php on line 40 and defined in C:\wamp64\www\portail\V1\php\vendor\genkgo\xsl\src\Xsl\Functions\CurrentGroup.php on line 69
Do you know how to deal with it ?
<?php
require __DIR__ . '/vendor/autoload.php';
use Genkgo\Xsl\XsltProcessor;
//XML
$xml_doc = new DOMDocument();
$xml_doc->load("../php/recupFile.xml");
// XSL
$xsl_doc = new DOMDocument();
$xsl_doc->load("../xslt/filtre_xml_tei.xsl");
// Proc
$proc = new XSLTProcessor();
$proc->importStylesheet($xsl_doc)
$proc->transformToDoc($xml_doc);
?>
The xsl and xsml files are pretty long but I can show it to you if you want. Sorry if the solution is obvious, it's the first time I use a php library. Thank you in advance.
Hi,
my xsl file works with xsltproc. But with your lib it doesn't parse the following part:
XML
<ItemTypes>
<Item id="test">
<Requirement id="subtest" min="10"/>
</Item>
</ItemTypes>
XSL
<xsl:apply-templates select="Requirement[name(id(@id))='Item']" mode="min"/>
<xsl:template match="Requirement|EffectReq" mode="min"><xsl:value-of select="count(id(@id)/preceding-sibling::*)"/> => <xsl:value-of select="@min"/><xsl:if test="position()!=last()">, </xsl:if>
</xsl:template>
Have you any idea?
There always have been some problems with Windows in combination with xsl:include
and/or streams
. There is no confirmation to date whether this library is working correctly on Windows.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.