Need help for DOM xsd validation

From: Date: Sun, 02 Dec 2007 11:08:40 +0000
Subject: Need help for DOM xsd validation
Groups: php.general 
Request: Send a blank email to php-general+get-265377@lists.php.net to get a copy of this message
Hi, I'm trying to load XML data into my script. That's no problem. The problem is, that the schema validation fails all time after loading a new document: Warning: DOMDocument::schemaValidate() [function.DOMDocument-schemaValidate]: Element '{http://www.desktopportal.de/Preferences}user': This element is not expected. Expected is ( user ). Funny is, if I'm creating and adding elements with php (DOMDocument etc.) and then validate the xml structure, no error occures. But if I reload this saved file next time when the script is reloading, I get a warning. Any ideas? Thanks, Matthias This is my xml file: <?xml version="1.0" encoding="UTF-8"?> <preferences xmlns="http://www.desktopportal.de/Preferences" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <user id="1"><webmail/></user> <user id="2"><webmail/></user> </preferences> This is my xsd file: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.desktopportal.de/Preferences" xmlns="http://www.desktopportal.de/Preferences" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="preferences" type="typePreferences"/>
    <xsd:complexType name="typePreferences">
    	<xsd:sequence>
    		<xsd:element name="user" type="typeUser" minOccurs="0" maxOccurs="unbounded"/>
    	</xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="typeUser">
    	<xsd:sequence>
    		<xsd:element name="webmail" type="typeWebmail" maxOccurs="1" minOccurs="1"/>
    	</xsd:sequence>
    	<xsd:attribute name="id" type="xsd:int" use="required"></xsd:attribute>
    </xsd:complexType>
    <xsd:complexType name="typeWebmail">
    	<xsd:sequence>
    		<xsd:element name="mailbox" type="typeMailbox" minOccurs="0" maxOccurs="unbounded"/>
    	</xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="typeMailbox">
    	<xsd:sequence>
    		<xsd:element name="box" type="typeBox" minOccurs="1" maxOccurs="unbounded"/>
    	</xsd:sequence>
    	<xsd:attribute name="id" type="xsd:int" use="required"></xsd:attribute>
    </xsd:complexType>
    <xsd:complexType name="typeBox">
    	<xsd:sequence>
    		<xsd:element name="visibility" type="xsd:boolean" minOccurs="1" maxOccurs="1"/>
    	</xsd:sequence>
    	<xsd:attribute name="name" type="xsd:string" use="required"></xsd:attribute>
    </xsd:complexType>
</xsd:schema>

« previous php.general (#265377) next »