Giter VIP home page Giter VIP logo

xsl's Issues

XSLT/SCH files

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);

Support for loops

  • Simple for loops: "1 to 10"
  • Using variables and return statements

Support all Xpath 2.0 functions

Source: Saxon

  • fn:abs
  • fn:adjust-dateTime-to-timezone
  • fn:adjust-dateTime-to-timezone
  • fn:adjust-date-to-timezone
  • fn:adjust-date-to-timezone
  • fn:adjust-time-to-timezone
  • fn:adjust-time-to-timezone
  • fn:avg
  • fn:base-uri
  • fn:base-uri
  • fn:boolean
  • fn:ceiling
  • fn:codepoints-to-string
  • fn:collection
  • fn:compare
  • fn:compare
  • fn:concat
  • fn:contains
  • fn:contains
  • fn:count
  • xslt:current
  • fn:current-date
  • fn:current-dateTime
  • xslt:current-group
  • xslt:current-grouping-key
  • fn:current-time
  • fn:data
  • fn:day-from-date
  • fn:day-from-dateTime
  • fn:days-from-duration
  • fn:deep-equal
  • fn:deep-equal
  • fn:default-collation
  • fn:distinct-nodes
  • fn:distinct-values
  • fn:distinct-values
  • fn:doc
  • xslt:document
  • xslt:document
  • fn:document-uri
  • xslt:element-available
  • fn:empty
  • fn:encode-for-uri
  • fn:ends-with
  • fn:ends-with
  • fn:error
  • fn:error
  • fn:escape-uri
  • fn:exactly-one
  • fn:exists
  • fn:expanded-QName
  • fn:false
  • fn:floor
  • xslt:format-date
  • xslt:format-date
  • xslt:format-dateTime
  • xslt:format-dateTime
  • xslt:format-number
  • xslt:format-number
  • xslt:format-time
  • xslt:format-time
  • xslt:function-available
  • xslt:function-available
  • xslt:generate-id
  • xslt:generate-id
  • fn:hours-from-dateTime
  • fn:hours-from-duration
  • fn:hours-from-time
  • fn:id
  • fn:idref
  • fn:implicit-timezone
  • fn:index-of
  • fn:index-of
  • fn:input
  • fn:in-scope-prefixes
  • fn:insert-before
  • xslt:key
  • fn:lang
  • fn:last
  • fn:local-name
  • fn:local-name
  • fn:local-name-from-QName
  • fn:lower-case
  • fn:matches
  • fn:matches
  • fn:max
  • fn:max
  • fn:min
  • fn:min
  • fn:minutes-from-dateTime
  • fn:minutes-from-duration
  • fn:minutes-from-time
  • fn:month-from-date
  • fn:month-from-dateTime
  • fn:months-from-duration
  • fn:name
  • fn:name
  • fn:namespace-uri
  • fn:namespace-uri
  • fn:namespace-uri-for-prefix
  • fn:namespace-uri-from-QName
  • fn:node-kind
  • fn:node-name
  • fn:normalize-space
  • fn:normalize-space
  • fn:normalize-unicode
  • fn:normalize-unicode
  • fn:not
  • fn:number
  • fn:number
  • fn:one-or-more
  • fn:position
  • xslt:regex-group
  • fn:remove
  • fn:replace
  • fn:replace
  • fn:resolve-QName
  • fn:resolve-uri
  • fn:resolve-uri
  • fn:reverse
  • fn:root
  • fn:root
  • fn:round
  • fn:round-half-to-even
  • fn:round-half-to-even
  • fn:seconds-from-dateTime
  • fn:seconds-from-duration
  • fn:seconds-from-time
  • fn:sequence-node-identical
  • fn:starts-with
  • fn:starts-with
  • fn:string
  • fn:string
  • fn:string-join
  • fn:string-length
  • fn:string-length
  • fn:string-to-codepoints
  • fn:subsequence
  • fn:subsequence
  • fn:substring
  • fn:substring
  • fn:substring-after
  • fn:substring-after
  • fn:substring-before
  • fn:substring-before
  • fn:subtract-dateTimes-yielding-dayTimeDuration
  • fn:subtract-dateTimes-yielding-yearMonthDuration
  • fn:sum
  • xslt:system-property
  • fn:timezone-from-date
  • fn:timezone-from-dateTime
  • fn:timezone-from-time
  • fn:tokenize
  • fn:tokenize
  • fn:trace
  • fn:translate
  • fn:true
  • fn:unordered
  • xslt:unparsed-entity-public-id
  • xslt:unparsed-entity-uri
  • xslt:unparsed-text
  • xslt:unparsed-text
  • fn:upper-case
  • fn:year-from-date
  • fn:year-from-dateTime
  • fn:years-from-duration
  • fn:zero-or-one

Catchable fatal error

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.

Support Xsl 2.0 elements

Looking for source with all xsl 2.0 elements.

  • xsl:function
  • xsl:for-each-group group-by
  • xsl:for-each-group group-adjacent
  • xsl:for-each-group group-starting-with
  • xsl:for-each-group group-ending-with
  • xsl:value-of: separator and sequences (BC break with XSL 1.0)
  • xsl:attribute with select and separator
  • xsl:perform-sort
  • xsl:sequence

Confirm support for Windows

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.

Crash when empty xs:date

PHP will crash with xs:date(xpath/to/element) when that xpath selection leads to a non-existing element.

template not parsing

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?

getting null issue

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).

Tests don't pass using PHP 7.4

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!

xsl:sequence

transformation error when using <xsl:sequence select="$data"/>
can u please fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.