5 changed files with 149 additions and 11 deletions
-
42ext/simplexml/simplexml.c
-
68ext/simplexml/tests/bug25756.phpt
-
24ext/simplexml/tests/bug25756.xsd
-
13ext/simplexml/tests/bug25756_1.xml
-
13ext/simplexml/tests/bug25756_2.xml
@ -0,0 +1,68 @@ |
|||
--TEST-- |
|||
Bug #25756 (validate_schema_file() broken) |
|||
--FILE-- |
|||
<?php |
|||
$dir = dirname(__FILE__); |
|||
$valid_schema_file = "$dir/bug25756.xsd"; |
|||
$invalid_schema_file = "$dir/bug25756_1.xml"; |
|||
$xml_file_1 = "$dir/bug25756_1.xml"; |
|||
$xml_file_2 = "$dir/bug25756_2.xml"; |
|||
|
|||
$s = simplexml_load_file($xml_file_1); |
|||
var_dump($s); |
|||
var_dump($s->validate_schema_file($valid_schema_file)); |
|||
var_dump($s->validate_schema_file($invalid_schema_file)); |
|||
$s = simplexml_load_file($xml_file_2); |
|||
var_dump($s); |
|||
var_dump($s->validate_schema_file($valid_schema_file)); |
|||
?> |
|||
--EXPECTF-- |
|||
object(simplexml_element)#1 (1) { |
|||
["items"]=> |
|||
object(simplexml_element)#2 (1) { |
|||
["item"]=> |
|||
array(2) { |
|||
[0]=> |
|||
object(simplexml_element)#3 (2) { |
|||
["product-name"]=> |
|||
string(3) "abc" |
|||
["quantity"]=> |
|||
string(3) "123" |
|||
} |
|||
[1]=> |
|||
object(simplexml_element)#4 (2) { |
|||
["product-name"]=> |
|||
string(3) "def" |
|||
["quantity"]=> |
|||
string(3) "456" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
bool(true) |
|||
|
|||
Warning: Unknown: Malformed XML Schema in %s on line %d |
|||
bool(false) |
|||
object(simplexml_element)#5 (1) { |
|||
["items"]=> |
|||
object(simplexml_element)#1 (1) { |
|||
["item"]=> |
|||
array(2) { |
|||
[0]=> |
|||
object(simplexml_element)#6 (2) { |
|||
["product-name"]=> |
|||
string(3) "abc" |
|||
["quantity"]=> |
|||
string(3) "abc" |
|||
} |
|||
[1]=> |
|||
object(simplexml_element)#7 (2) { |
|||
["product-name"]=> |
|||
string(3) "abc" |
|||
["quantity"]=> |
|||
string(3) "123" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
bool(false) |
|||
@ -0,0 +1,24 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
|||
<xsd:element name="foo" type="foo-type" /> |
|||
<xsd:complexType name="item-type"> |
|||
<xsd:all> |
|||
<xsd:element name="product-name" type="xsd:string" |
|||
minOccurs="1" maxOccurs="1"/> |
|||
<xsd:element name="quantity" type="xsd:decimal" |
|||
minOccurs="1" maxOccurs="1"/> |
|||
</xsd:all> |
|||
</xsd:complexType> |
|||
<xsd:complexType name="foo-type"> |
|||
<xsd:sequence> |
|||
<xsd:element name="items" minoccurs="1" maxOccurs="1"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="item" type="item-type" |
|||
minOccurs="0" maxOccurs="unbounded" /> |
|||
</xsd:sequence> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:sequence> |
|||
</xsd:complexType> |
|||
</xsd:schema> |
|||
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<foo> |
|||
<items> |
|||
<item> |
|||
<product-name>abc</product-name> |
|||
<quantity>123</quantity> |
|||
</item> |
|||
<item> |
|||
<product-name>def</product-name> |
|||
<quantity>456</quantity> |
|||
</item> |
|||
</items> |
|||
</foo> |
|||
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<foo> |
|||
<items> |
|||
<item> |
|||
<product-name>abc</product-name> |
|||
<quantity>abc</quantity> |
|||
</item> |
|||
<item> |
|||
<product-name>abc</product-name> |
|||
<quantity>123</quantity> |
|||
</item> |
|||
</items> |
|||
</foo> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue