php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79391 Dom validate schema does not support XML Schema 1.1
Submitted: 2020-03-18 11:07 UTC Modified: 2020-10-23 13:01 UTC
From: joao dot rebelo at pchouse dot pt Assigned: cmb (profile)
Status: Closed Package: DOM XML related
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joao dot rebelo at pchouse dot pt
New email:
PHP Version: OS:

 

 [2020-03-18 11:07 UTC] joao dot rebelo at pchouse dot pt
Description:
------------
Dom validate schema does not accepts tag <xs:assert test="..." />, part of xsd

 <xs:sequence>
                <xs:element ref="TaxonomyReference"/>
                <xs:element name="Account" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="AccountID" type="SAFPTGLAccountID"/>
                            <xs:element ref="AccountDescription"/>
                            <xs:element ref="OpeningDebitBalance"/>
                            <xs:element ref="OpeningCreditBalance"/>
                            <xs:element ref="ClosingDebitBalance"/>
                            <xs:element ref="ClosingCreditBalance"/>
                            <xs:element ref="GroupingCategory"/>
                            <xs:element name="GroupingCode" type="SAFPTGLAccountID" minOccurs="0"/>
                            <xs:element name="TaxonomyCode" type="SAFTaxonomyCode" minOccurs="0"/>
                        </xs:sequence>
                        <xs:assert
                            test="
                                if ((ns:GroupingCategory != 'GM' and not(ns:TaxonomyCode)) or (ns:GroupingCategory eq 'GM' and ns:TaxonomyCode)) then
                                    true()
                                else
                                    false()"
                        />
                        <xs:assert
                            test="
                            if ((ns:GroupingCategory eq 'GR' and not(ns:GroupingCode)) or (ns:GroupingCategory eq 'AR' and not(ns:GroupingCode)) or (ns:GroupingCategory eq 'GA' and ns:GroupingCode) or (ns:GroupingCategory eq 'AA' and ns:GroupingCode) or (ns:GroupingCategory eq 'GM' and ns:GroupingCode) or (ns:GroupingCategory eq 'AM' and ns:GroupingCode)) then
                            true()
                            else
                            false()"
                        />
                    </xs:complexType>

Test script:
---------------
        try
        {
            \libxml_use_internal_errors(true);
            $validate = true;
            $dom      = new \DOMDocument("1.0", "ISO-8859-1");
            $dom->load("D:/Downloads/saftpt1.04_01.xsd");
            $validate = $dom->schemaValidate(self::XSD_PATH);
        }
        catch (\Exception $e)
        {
            $allErrors = libxml_get_errors();
            $a         = $e->getMessage();
        }

Expected result:
----------------
Should accept the xsd to validate the xml

Actual result:
--------------
Throws error,
[0] => LibXMLError object {
    level => (int) 2
    code => (int) 3033
    column => (int) 0
    message => (string) Element '{http://www.w3.org/2001/XMLSchema}complexType': The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))).

    file => (string) file:/D:/NetBeansProjects/PHP/Saft-PT_4_PHP/tests/Rebelo/Test/../../Ressources/saftpt1.04_01.xsd
    line => (int) 196

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-18 11:46 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-03-18 11:46 UTC] cmb@php.net
Isn't that supposed to be <xs:assertion>?
 [2020-03-18 12:09 UTC] joao dot rebelo at pchouse dot pt
-Status: Feedback +Status: Assigned
 [2020-03-18 12:09 UTC] joao dot rebelo at pchouse dot pt
About;
Isn't that supposed to be <xs:assertion>?

I think not the xsd file is from the Portuguese Tax Authotity and works fine in Java app.

The link of the xsd file is:
http://info.portaldasfinancas.gov.pt/apps/saft-pt04/saftpt1.04_01.xsd


And a xml example file is here:
https://info.portaldasfinancas.gov.pt/apps/saft-pt01/local/saft_idemo599999999.xml
 [2020-04-02 11:28 UTC] cmb@php.net
-Status: Assigned +Status: Open -Assigned To: cmb +Assigned To:
 [2020-04-02 11:28 UTC] cmb@php.net
Thanks for providing the XSD and the example!

I can confirm the reported behavior; I'm not sure about the cause.
There *might* be a bug in libxml2.
 [2020-06-05 16:45 UTC] joao dot rebelo at pchouse dot pt
-Status: Open +Status: Closed
 [2020-06-05 16:45 UTC] joao dot rebelo at pchouse dot pt
The issue is from libxml2, response:

https://gitlab.gnome.org/GNOME/libxml2/-/issues/162#note_829986

<xs:assert> is an XML Schema 1.1 feature. libxml2 only supports XML Schema 1.0.
 [2020-06-06 11:28 UTC] cmb@php.net
-Summary: Dom validate schema does not accepts tag <xs:assert test="..." /> +Summary: Dom validate schema does not support XML Schema 1.1 -Status: Closed +Status: Re-Opened -Type: Bug +Type: Documentation Problem
 [2020-06-06 11:28 UTC] cmb@php.net
Thanks for the follow-up!

I think this "detail" should be documented.
 [2020-10-23 13:01 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-10-23 13:02 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=ea90b5fa48ce2f8d3126d4230b4b84afedaafd87
Log: Fix #79391: Dom validate schema does not support XML Schema 1.1
 [2020-10-23 13:02 UTC] phpdocbot@php.net
-Status: Re-Opened +Status: Closed
 [2020-10-23 19:15 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=b76ea18d21589442a1ee64613c62bfdddfc902e3
Log: Fix #79391: Dom validate schema does not support XML Schema 1.1
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Oct 31 08:01:23 2020 UTC