php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79391 Dom validate schema does not accepts tag <xs:assert test="..." />
Submitted: 2020-03-18 11:07 UTC Modified: 2020-03-18 12:09 UTC
From: joao dot rebelo at pchouse dot pt Assigned: cmb (profile)
Status: Assigned Package: DOM XML related
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Mar 31 23:01:23 2020 UTC