Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.8.6

Bug #7890 Generated Schema Does not Validate Against DTD
Submitted: 2006-06-13 16:59 UTC
From: michael at apison dot com Assigned: ifeghali
Status: Closed Package: MDB2_Schema (version 0.5.0)
PHP Version: Irrelevant OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 9 + 10 = ?

 
 [2006-06-13 16:59 UTC] michael at apison dot com (Michael Caplan)
Description: ------------ Hi Lukas, There appears to be a problem with the supplied DTD (or the generated MDB2_Schema XML). The below generated XML does not validate. I assume it is because the DTD? Test script: --------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE database SYSTEM "http://cvs.php.net/viewcvs.cgi/*checkout*/pear/MDB2_Schema/docs/MDB.dtd"> <database> <name>framework</name> <create>true</create> <overwrite>false</overwrite> <table> <name>files</name> <declaration> <field> <name>files_path</name> <type>text</type> <length>255</length> <notnull>true</notnull> <default>/</default> </field> <field> <name>files_name</name> <type>text</type> <length>255</length> <notnull>true</notnull> <default></default> </field> <field> <name>files_type</name> <type>integer</type> <unsigned>false</unsigned> <length>1</length> <notnull>true</notnull> <default>0</default> </field> <field> <name>files_data</name> <type>blob</type> <notnull>false</notnull> </field> <field> <name>files_mime</name> <type>text</type> <length>255</length> <notnull>false</notnull> <default></default> </field> <field> <name>files_right</name> <type>integer</type> <unsigned>false</unsigned> <notnull>true</notnull> <default>0</default> </field> <field> <name>files_modified</name> <type>timestamp</type> <notnull>true</notnull> <default>0000-00-00 00:00:00</default> </field> <field> <name>files_owner</name> <type>text</type> <unsigned>false</unsigned> <length>32</length> <notnull>true</notnull> <default>0</default> </field> <index> <name>primary</name> <primary>true</primary> <field> <name>files_path</name> <sorting>ascending</sorting> </field> <field> <name>files_name</name> <sorting>ascending</sorting> </field> <field> <name>files_type</name> <sorting>ascending</sorting> </field> </index> </declaration> </table> </database> Actual result: -------------- xmllint --valid modules/files/db/schema.xml modules/files/db/schema.xml:93: element index: validity error : Element index content does not follow the DTD, expecting (name+ | was? | unique? | primary? | field+), got (name primary field field field ) </index> ^

Comments

 [2006-06-19 23:52 UTC] ifeghali (Igor Feghali)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. DTD fixed. the attached XML is now validating.
 [2006-06-27 17:45 UTC] michael at apison dot com
Hi Igor and Lukas, As discussed on the PEAR list, I am still having some issues with the supplied DTD. Specifically, any table that defines multiple indexes fails. Below is an updatred DTD that fixes this issue. I'm also including an updated XML schema file (which was autogenerated from oXygen) which should bring the schema in line with the DTD. Best, Michael DTD --- <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT comments (#PCDATA)> <!ELEMENT create (#PCDATA)> <!ELEMENT default (#PCDATA)> <!ELEMENT description (#PCDATA)> <!ELEMENT length (#PCDATA | variable)*> <!ELEMENT name (#PCDATA)> <!ELEMENT notnull (#PCDATA)> <!ELEMENT overwrite (#PCDATA)> <!ELEMENT sorting (#PCDATA)> <!ELEMENT start (#PCDATA)> <!ELEMENT type (#PCDATA)> <!ELEMENT unique (#PCDATA)> <!ELEMENT primary (#PCDATA)> <!ELEMENT autoincrement (#PCDATA)> <!ELEMENT unsigned (#PCDATA)> <!ELEMENT value (#PCDATA)> <!ELEMENT variable (#PCDATA)> <!ELEMENT was (#PCDATA)> <!ELEMENT database (name+ | create? | overwrite? | description? | comments? | table+ | sequence?)*> <!ELEMENT field (#PCDATA | name | was | type | default | notnull | autoincrement | unsigned | description | comments | length | sorting | value)*> <!ELEMENT table (#PCDATA | name | was | description | comments | declaration | initialization)*> <!ELEMENT sequence (name+ | was? | start? | on+ | description? | comments?)*> <!ELEMENT index (name+ | was? | unique? | primary? | field+)*> <!ELEMENT declaration (field+, index*)> <!ELEMENT initialization (insert)> <!ELEMENT insert (field+)> <!ELEMENT on (table, field)+> XML Schema ---------- <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="comments" type="xs:string"/> <xs:element name="create" type="xs:string"/> <xs:element name="default" type="xs:string"/> <xs:element name="description" type="xs:string"/> <xs:element name="length"> <xs:complexType mixed="true"> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" ref="variable"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="name" type="xs:string"/> <xs:element name="notnull" type="xs:string"/> <xs:element name="overwrite" type="xs:string"/> <xs:element name="sorting" type="xs:string"/> <xs:element name="start" type="xs:string"/> <xs:element name="type" type="xs:string"/> <xs:element name="unique" type="xs:string"/> <xs:element name="primary" type="xs:string"/> <xs:element name="autoincrement" type="xs:string"/> <xs:element name="unsigned" type="xs:string"/> <xs:element name="value" type="xs:string"/> <xs:element name="variable" type="xs:string"/> <xs:element name="was" type="xs:string"/> <xs:element name="database"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element maxOccurs="unbounded" ref="name"/> <xs:element minOccurs="0" ref="create"/> <xs:element minOccurs="0" ref="overwrite"/> <xs:element minOccurs="0" ref="description"/> <xs:element minOccurs="0" ref="comments"/> <xs:element maxOccurs="unbounded" ref="table"/> <xs:element minOccurs="0" ref="sequence"/> </xs:choice> </xs:complexType> </xs:element> <xs:element name="field"> <xs:complexType mixed="true"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="name"/> <xs:element ref="was"/> <xs:element ref="type"/> <xs:element ref="default"/> <xs:element ref="notnull"/> <xs:element ref="autoincrement"/> <xs:element ref="unsigned"/> <xs:element ref="description"/> <xs:element ref="comments"/> <xs:element ref="length"/> <xs:element ref="sorting"/> <xs:element ref="value"/> </xs:choice> </xs:complexType> </xs:element> <xs:element name="table"> <xs:complexType mixed="true"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="name"/> <xs:element ref="was"/> <xs:element ref="description"/> <xs:element ref="comments"/> <xs:element ref="declaration"/> <xs:element ref="initialization"/> </xs:choice> </xs:complexType> </xs:element> <xs:element name="sequence"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element maxOccurs="unbounded" ref="name"/> <xs:element minOccurs="0" ref="was"/> <xs:element minOccurs="0" ref="start"/> <xs:element maxOccurs="unbounded" ref="on"/> <xs:element minOccurs="0" ref="description"/> <xs:element minOccurs="0" ref="comments"/> </xs:choice> </xs:complexType> </xs:element> <xs:element name="index"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element maxOccurs="unbounded" ref="name"/> <xs:element minOccurs="0" ref="was"/> <xs:element minOccurs="0" ref="unique"/> <xs:element minOccurs="0" ref="primary"/> <xs:element maxOccurs="unbounded" ref="field"/> </xs:choice> </xs:complexType> </xs:element> <xs:element name="declaration"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="field"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="index"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="initialization" type="insert"/> <xs:complexType name="insert"> <xs:sequence> <xs:element ref="insert"/> </xs:sequence> </xs:complexType> <xs:element name="insert"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" ref="field"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="on"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="table"/> <xs:element ref="field"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
 [2006-06-28 01:28 UTC] ifeghali (Igor Feghali)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. DTD fixed as sugested by Michael.
 [2006-07-04 14:48 UTC] michael at apison dot com
Hi Guys, I came across two more issues with the DTD. The first is multiple instances of insert in the initialization element. The below update fixes this. The second is the use of the variable element throughout an XML file. The DTD only makes reference to the lenght element containing zero or more instances of pcdata or variable. I know that the variable element can be used in other circumstnace as well, but am not sure what limits are placed on variable element usage. Best, Mike <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT comments (#PCDATA)> <!ELEMENT create (#PCDATA)> <!ELEMENT default (#PCDATA)> <!ELEMENT description (#PCDATA)> <!ELEMENT length (#PCDATA | variable)*> <!ELEMENT name (#PCDATA)> <!ELEMENT notnull (#PCDATA)> <!ELEMENT overwrite (#PCDATA)> <!ELEMENT sorting (#PCDATA)> <!ELEMENT start (#PCDATA)> <!ELEMENT type (#PCDATA)> <!ELEMENT unique (#PCDATA)> <!ELEMENT primary (#PCDATA)> <!ELEMENT autoincrement (#PCDATA)> <!ELEMENT unsigned (#PCDATA)> <!ELEMENT value (#PCDATA)> <!ELEMENT variable (#PCDATA)> <!ELEMENT was (#PCDATA)> <!ELEMENT database (name+ | create? | overwrite? | description? | comments? | table+ | sequence?)*> <!ELEMENT field (#PCDATA | name | was | type | default | notnull | autoincrement | unsigned | description | comments | length | sorting | value)*> <!ELEMENT table (#PCDATA | name | was | description | comments | declaration | initialization)*> <!ELEMENT sequence (name+ | was? | start? | on+ | description? | comments?)*> <!ELEMENT index (name+ | was? | unique? | primary? | field+)*> <!ELEMENT declaration (field+, index*)> <!ELEMENT initialization (insert*)> <!ELEMENT insert (field+)> <!ELEMENT on (table, field)+>
 [2006-07-04 16:16 UTC] ifeghali (Igor Feghali)
Hello Michael, I am taking a look at this.
 [2006-07-04 17:17 UTC] ifeghali (Igor Feghali)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Initialization element redefined to hold one or more insert.
 [2006-07-04 17:33 UTC] michael at apison dot com
Hi Igor, Thanks for committing my fix. This however does not address the use of variable elements throughout the schema. As it sounds right now, the only DTD valid spot to place a variable element is within the length element. I know that the name, create, overwrite are also comment elements to use variables, but according to the DTD this is illegal. Thanks, mike
 [2006-07-05 15:04 UTC] ifeghali (Igor Feghali)
Hello Michael, Please could you open a new bug report for the <variable> issue? Please don't forget to point out the elements you want to have <variable> placed in. Regards, Igor.