But I'd like to use this (doesn't validate with the xml) (in mysql.xsd): <
xs:complexType name=
"table">
<
xs:sequence>
<
xs:element name=
"field" type=
"mysql:field" minOccurs=
"0" maxOccurs=
"unbounded" />
</
xs:sequence>
<
xs:attribute name=
"name" type=
"xs:string" use=
"required" />
</
xs:complexType>
[..]
<
xs:complexType name=
"field">
<
xs:attribute name=
"name" type=
"xs:string" use=
"required" />
<
xs:attribute name=
"table" type=
"xs:string" use=
"optional" />
</
xs:complexType>This is probably the only way out, if I'm trying to extend using the same tagname (but stronger validation because of parent element). This doesnt work (in mysql.xsd): <
xs:complexType name=
"cond">
<
xs:sequence>
<
xs:element name=
"field" minOccurs=
"0" maxOccurs=
"unbounded">
<
xs:complexType>
<
xs:complexContent>
<
xs:extension base=
"field">
<
xs:attribute name=
"operator" type=
"xs:string" use=
"required" />
</
xs:extension>
</
xs:complexContent>
</
xs:complexType>
</
xs:element>
</
xs:sequence>
</
xs:complexType>I don't understand what I'm doing wrong, because all google code snippets + w3 works does say this should be right. I've been shuffling around with targetnamespace and so on, but it didn't work outThis error i get very much:Warning: DOMDocument::schemaValidate() [
function.DOMDocument-schemaValidate]: Validation failed: no DTD found !Element '{http://sove.nl/ns/system/mysql/}field': This element is not expected. Expected is ( field ). in /var/www/client/sove.nl/httpdocs/xmysql_mysql.php on line 34So it's expecting an element with a blank namespace, but it's defined inside the MYSQL namespace (but is ignored)How can I get my extension to work? Please help, been trying for days now. Big thanks, Robert de Wilde Here are my full source codes (better don't quote them i guess): XMYSQL_MYSQL.PHP<?php $library = new SchemaDOMDocument("1.0");
$library->validateOnParse = true;
$library->load('xmysql_mysql.xml');
$library->validateXMLSchemas();
class SchemaDOMDocument extends DOMDocument
{
public function validateXMLSchemas()
{
$schemaLocation = $this->documentElement->getAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');
if (! $schemaLocation) {
throw new DOMException('No schemas found');
}
/* the schemaLocation contains pairs of values separated by spaces the first value in each pair
is the name space to be validated. The second is a URI defining the location of the schema
validate each namespace using the provided URI
*/
$pairs = preg_split('/\s+/', $schemaLocation);
$pairCount = count($pairs);
if ($pairCount <= 1) {
throw new DOMException('Invalid schema location value.');
}
$valid = true;
for($x = 1; $x < $pairCount; $x+=2) {
$valid = $this->schemaValidate($pairs[$x]) && $valid;
}
if(! $valid) {
throw new DOMException('XML Schema Validation Failure');
}
return true;
}
} ?>
XMYSQL_MYSQL.XML:<?xml version="1.0" encoding="utf-8"?><stream xmlns="
http://sove.nl/ns/core/"
xmlns:mysql="
http://sove.nl/ns/system/mysql/"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://sove.nl/ns/core/ http://sove.nl/ns/core.xsd">
<mysql:set>
<mysql:query type="select">
<mysql:table name="objects">
<mysql:field name="objectid" />
<mysql:field name="objectname" />
<mysql:field name="objectgroup" />
</mysql:table>
<mysql:table name="settings">
<mysql:field name="settingtimezone" />
</mysql:table>
<mysql:join>
<mysql:table name="extended">
<mysql:field name="extendedobjectid" />
<mysql:field name="extendedinfo" />
</mysql:table>
<mysql:cond>
<mysql:field name="extendedobjectid" table="extended" />
</mysql:cond>
</mysql:join>
<mysql:cond>
<mysql:field name="objectid" table="objects" />
</mysql:cond>
<mysql:order type="desc">
<mysql:field name="objectid" table="objects" />
</mysql:order>
<mysql:group>
<mysql:field name="objectid" table="objects" />
</mysql:group>
</mysql:query>
</mysql:set>
</stream> CORE.XSD<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns="
http://sove.nl/ns/core/" xmlns:mysql="
http://sove.nl/ns/system/mysql/" xmlns:xs="
http://www.w3.org/2001/XMLSchema" targetNamespace="
http://sove.nl/ns/core/">
<!-- ## SYSTEM ## //-->
<xs:import namespace="
http://sove.nl/ns/system/mysql/" schemaLocation="
http://sove.nl/ns/system/mysql.xsd"/>
<!-- ## TYPES ## //-->
<!--<xs:import namespace="
http://sove.nl/ns/types/boek/" schemaLocation="
http://sove.nl/ns/types/boek.xsd"/>//-->
<xs:complexType name="stream">
<xs:sequence>
<xs:element ref="mysql:set"/>
</xs:sequence>
</xs:complexType>
<xs:element name="stream" type="stream" />
</xs:schema> MYSQL.XSD<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns="
http://sove.nl/ns/system/mysql/" xmlns:xs="
http://www.w3.org/2001/XMLSchema" targetNamespace="
http://sove.nl/ns/system/mysql/">
<xs:complexType name="set">
<xs:sequence>
<xs:element ref="query"/>
</xs:sequence>
</xs:complexType> <xs:complexType name="query">
<xs:sequence>
<xs:element ref="table" minOccurs="1" maxOccurs="unbounded" />
<xs:element ref="query" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="join" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="cond" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="order" minOccurs="0" maxOccurs="1" />
<xs:element ref="group" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="type" type="xs:string" />
</xs:complexType>
<xs:complexType name="table">
<xs:sequence>
<xs:element ref="field" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="field">
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="table" type="xs:string" use="optional" />
</xs:complexType> <xs:complexType name="join">
<xs:sequence>
<xs:element ref="table" minOccurs="1" />
<xs:element ref="join" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="cond" minOccurs="1" />
</xs:sequence>
</xs:complexType> <xs:complexType name="cond">
<xs:sequence>
<xs:element name="field" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="field">
<xs:attribute name="operator" type="xs:string" use="required" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType> <xs:complexType name="order">
<xs:sequence>
<xs:element ref="field" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="table" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="type" type="xs:string" />
</xs:complexType> <xs:complexType name="group">
<xs:sequence>
<xs:element ref="field" minOccurs="0" maxOccurs="unbounded" />
<xs:element ref="table" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:element name="set" type="set" />
<xs:element name="query" type="query" />
<xs:element name="table" type="table" />
<xs:element name="field" type="field" />
<xs:element name="join" type="join" />
<xs:element name="cond" type="cond" />
<xs:element name="order" type="order" />
<xs:element name="group" type="group" />
</xs:schema>Robert de Wilde
wilde825 <at> planet.nl