Bug #79391 [Asn->Opn]: Dom validate schema does not accepts tag <xs:assert test="..." />
| From: | cmb@php.net | Date: | Thu, 02 Apr 2020 11:28:10 +0000 |
| Subject: | Bug #79391 [Asn->Opn]: Dom validate schema does not accepts tag <xs:assert test="..." /> | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226411@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79391&edit=1
ID: 79391
Updated by: cmb@php.net
Reported by: joao dot rebelo at pchouse dot pt
Summary: Dom validate schema does not accepts tag <xs:assert
test="..." />
-Status: Assigned
+Status: Open
Type: Bug
Package: DOM XML related
Operating System: Windows
PHP Version: Irrelevant
-Assigned To: cmb
+Assigned To:
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2020-03-18 12:09:38] 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-03-18 11:46:57] cmb@php.net
Isn't that supposed to be <xs:assertion>?
------------------------------------------------------------------------
[2020-03-18 11:07:52] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79391&edit=1