php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33880 Bug in function "schemaValidate"
Submitted: 2005-07-27 08:47 UTC Modified: 2005-07-27 12:20 UTC
From: thomas dot wetzler at siemens dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.4 OS: SUN OS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thomas dot wetzler at siemens dot com
New email:
PHP Version: OS:

 

 [2005-07-27 08:47 UTC] thomas dot wetzler at siemens dot com
Description:
------------
To validate a dataset, I try to generate a XML-Schema with the help of an database-definition. The Schema-file is correctly build. XMLSpy works with it fine... but if I try to run the same files with php, php reports a failure.



Reproduce code:
---------------
test.php:
#!/wir/webadmin/share/php504/bin/php
<?

$xml = new DOMDocument(); 
$xml->load('gd.xml'); 
if ($xml->schemaValidate("gd.xsd")) { 
     echo "Validated OK"; 
} else { 
     echo "Validate FAILED"; 
} 

?>
--------------------------------------------
gd.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) -->
<element xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="D:\gp.xsd">
	<subelement>
		<header>PN</header>
		<content> 10149764</content>
	</subelement>
	<subelement>
		<header>DT</header>
		<content> DEB4 PATENTSCHRIFT</content>
	</subelement>
	<subelement>
		<header>PA</header>
		<content> Huettlin, Herbert, Dr.h.c., 79539 Loerrach, DE.</content>
	</subelement>
	<subelement>
		<header>IN</header>
		<content> Huettlin, Herbert, Dr.h.c., 79539 Loerrach, DE.</content>
	</subelement>
</element>

--------------------------------------------------------
gd.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
	<xs:attributeGroup name="controlsequences">
		<xs:attribute name="pre" type="xs:string"/>
		<xs:attribute name="post" type="xs:string"/>
	</xs:attributeGroup>
	<xs:complexType name="type_subelement">
		<xs:choice>
			<xs:sequence>
				<xs:element name="header" type="columns" fixed="AN"/>
				<xs:element name="content" type="type_an"/>
			</xs:sequence>
			<xs:sequence>
				<xs:element name="header" type="columns" fixed="PN"/>
				<xs:element name="content" type="type_pn"/>
			</xs:sequence>
			<xs:sequence>
				<xs:element name="header" type="columns" fixed="IN"/>
				<xs:element name="content" type="type_in"/>
			</xs:sequence>
			<xs:sequence>
				<xs:element name="header" type="columns" fixed="PA"/>
				<xs:element name="content" type="type_pa"/>
			</xs:sequence>
			<xs:sequence>
				<xs:element name="header" type="columns" fixed="DT"/>
				<xs:element name="content" type="type_dt"/>
			</xs:sequence>
		</xs:choice>
	</xs:complexType>
	<xs:simpleType name="columns">
		<xs:restriction base="xs:string">
			<xs:enumeration value="AN"/>
			<xs:enumeration value="PN"/>
			<xs:enumeration value="IN"/>
			<xs:enumeration value="PA"/>
			<xs:enumeration value="DT"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="type_an">
		<xs:restriction base="xs:string">
			<xs:maxLength value="80"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="type_pn">
		<xs:restriction base="xs:string">
			<xs:maxLength value="1600"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="type_in">
		<xs:restriction base="xs:string">
			<xs:maxLength value="1600"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="type_pa">
		<xs:restriction base="xs:string">
			<xs:maxLength value="1600"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="type_dt">
		<xs:restriction base="xs:string">
			<xs:maxLength value="1600"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:element name="subelement" type="type_subelement"/>
	<xs:element name="element">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="subelement" maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>




Expected result:
----------------
Validated OK

Actual result:
--------------
Warning: Element decl. 'subelement': The content model is not determinist. in /wir/searchservertest/src/load_db/xml_parser/test.php on line 6

Warning: Invalid Schema in /wir/searchservertest/src/load_db/xml_parser/test.php on line 6
Validate FAILED

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-27 12:20 UTC] chregu@php.net
the actual XML Schema parsing is done by libxml2 and not PHP. So any XML Schema "bug" is a libxml2 issue.

I recommend first updating to the latest libxml2 release (2.6.20) as the XML Schema support made big improvements lately and if the bug persits, ask on the libxml2 mailinglist (or file a bug report there)

nothing we can do about.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 16:01:30 2025 UTC