1
0
mirror of synced 2024-12-05 03:06:05 +03:00

[DDC-2429] Fix xsd definition

This commit is contained in:
Fabio B. Silva 2013-05-13 11:04:36 -03:00
parent eb1a162cbc
commit b147c472be
8 changed files with 98 additions and 62 deletions

View File

@ -37,6 +37,7 @@
<xs:element name="cascade-merge" type="orm:emptyType" minOccurs="0"/>
<xs:element name="cascade-remove" type="orm:emptyType" minOccurs="0"/>
<xs:element name="cascade-refresh" type="orm:emptyType" minOccurs="0"/>
<xs:element name="cascade-detach" type="orm:emptyType" minOccurs="0"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:anyAttribute namespace="##other"/>
@ -86,8 +87,11 @@
</xs:complexType>
<xs:complexType name="named-native-query">
<xs:sequence>
<xs:element name="query" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="query" type="xs:string" use="required"/>
<xs:attribute name="result-class" type="xs:string" />
<xs:attribute name="result-set-mapping" type="xs:string" />
</xs:complexType>
@ -95,14 +99,14 @@
<xs:complexType name="named-native-queries">
<xs:sequence>
<xs:element name="named-native-query" type="orm:named-native-query" minOccurs="1" maxOccurs="unbounded" />
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="entity-listener">
<xs:sequence>
<xs:element name="lifecycle-callback" type="orm:lifecycle-callback" minOccurs="0" maxOccurs="unbounded"/>
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="class" type="xs:string"/>
</xs:complexType>
@ -127,20 +131,24 @@
<xs:element name="field-result" type="orm:field-result" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="entity-class" type="xs:string" use="required" />
<xs:attribute name="discriminator-column" type="xs:string" use="optional" />
</xs:complexType>
<xs:complexType name="sql-result-set-mapping">
<xs:sequence>
<xs:element name="entity-result" type="orm:entity-result" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="column-result" type="orm:column-result" minOccurs="0" maxOccurs="unbounded" />
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="entity-result" type="orm:entity-result"/>
<xs:element name="column-result" type="orm:column-result"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:choice>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
</xs:complexType>
<xs:complexType name="sql-result-set-mappings">
<xs:sequence>
<xs:element name="sql-result-set-mapping" type="orm:sql-result-set-mapping" minOccurs="1" maxOccurs="unbounded" />
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
</xs:complexType>
@ -155,6 +163,7 @@
<xs:element name="entity-listeners" type="orm:entity-listeners" minOccurs="0" maxOccurs="1" />
<xs:element name="named-queries" type="orm:named-queries" minOccurs="0" maxOccurs="1" />
<xs:element name="named-native-queries" type="orm:named-native-queries" minOccurs="0" maxOccurs="1" />
<xs:element name="sql-result-set-mappings" type="orm:sql-result-set-mappings" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="id" type="orm:id" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="field" type="orm:field" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="one-to-one" type="orm:one-to-one" minOccurs="0" maxOccurs="unbounded"/>
@ -221,6 +230,7 @@
<xs:simpleType name="generator-strategy">
<xs:restriction base="xs:token">
<xs:enumeration value="NONE"/>
<xs:enumeration value="TABLE"/>
<xs:enumeration value="SEQUENCE"/>
<xs:enumeration value="IDENTITY"/>
@ -380,7 +390,7 @@
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NMTOKEN" use="required" />
<xs:attribute name="name" type="xs:NMTOKEN" use="optional" />
<xs:attribute name="referenced-column-name" type="xs:NMTOKEN" use="optional" default="id" />
<xs:attribute name="unique" type="xs:boolean" default="false" />
<xs:attribute name="nullable" type="xs:boolean" default="true" />
@ -505,7 +515,7 @@
<xs:complexType name="association-overrides">
<xs:sequence>
<xs:element name="association-override" type="orm:association-override" minOccurs="1" maxOccurs="unbounded" />
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
</xs:complexType>
@ -521,16 +531,33 @@
<xs:complexType name="attribute-overrides">
<xs:sequence>
<xs:element name="attribute-override" type="orm:attribute-override" minOccurs="1" maxOccurs="unbounded" />
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="attribute-override">
<xs:sequence>
<xs:element name="field" type="orm:field" minOccurs="1" />
<xs:any minOccurs="1" maxOccurs="unbounded" namespace="##other"/>
<xs:element name="field" type="orm:attribute-override-field" minOccurs="1" />
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NMTOKEN" use="required" />
</xs:complexType>
<xs:complexType name="attribute-override-field">
<xs:sequence>
<xs:element name="options" type="orm:options" minOccurs="0" />
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
</xs:sequence>
<xs:attribute name="type" type="xs:NMTOKEN" default="string" />
<xs:attribute name="column" type="xs:NMTOKEN" />
<xs:attribute name="length" type="xs:NMTOKEN" />
<xs:attribute name="unique" type="xs:boolean" default="false" />
<xs:attribute name="nullable" type="xs:boolean" default="false" />
<xs:attribute name="version" type="xs:boolean" />
<xs:attribute name="column-definition" type="xs:string" />
<xs:attribute name="precision" type="xs:integer" use="optional" />
<xs:attribute name="scale" type="xs:integer" use="optional" />
<xs:anyAttribute namespace="##other"/>
</xs:complexType>
</xs:schema>

View File

@ -66,23 +66,32 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
/**
* @param string $xmlMappingFile
* @dataProvider dataValidSchema
* @group DDC-2429
*/
public function testValidateXmlSchema($xmlMappingFile)
{
$xsdSchemaFile = __DIR__ . "/../../../../../doctrine-mapping.xsd";
$xsdSchemaFile = __DIR__ . '/../../../../../doctrine-mapping.xsd';
$dom = new \DOMDocument('UTF-8');
$dom = new \DOMDocument('UTF-8');
$dom->load($xmlMappingFile);
$this->assertTrue($dom->schemaValidate($xsdSchemaFile));
}
static public function dataValidSchema()
{
return array(
array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.CTI.dcm.xml"),
array(__DIR__ . "/xml/Doctrine.Tests.ORM.Mapping.User.dcm.xml"),
array(__DIR__ . "/xml/CatNoId.dcm.xml"),
$list = glob(__DIR__ . '/xml/*.xml');
$invalid = array(
'Doctrine.Tests.Models.DDC889.DDC889Class.dcm'
);
$list = array_filter($list, function($item) use ($invalid){
return ! in_array(pathinfo($item, PATHINFO_FILENAME), $invalid);
});
return array_map(function($item){
return array($item);
}, $list);
}
/**

View File

@ -1,12 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\Models\CMS\CmsAddress" table="cms_users">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\Models\CMS\CmsAddress" table="cms_users">
<entity-listeners>
<entity-listener class="CmsAddressListener"/>
</entity-listeners>
@ -15,7 +13,7 @@
<named-native-query name="find-all" result-set-mapping="mapping-find-all">
<query>SELECT id, country, city FROM cms_addresses</query>
</named-native-query>
<named-native-query name="find-by-id" result-class="CmsAddress">
<query>SELECT * FROM cms_addresses WHERE id = ?</query>
</named-native-query>
@ -46,7 +44,7 @@
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
<field name="country" column="country" type="string" length="50"/>
<field name="city" column="city" type="string" length="50"/>
<field name="zip" column="zip" type="string" length="50"/>
@ -54,6 +52,7 @@
<one-to-one field="user" target-entity="CmsUser" inversed-by="address">
<join-column referenced-column-name="id" />
</one-to-one>
</entity>
</doctrine-mapping>

View File

@ -15,7 +15,7 @@
<named-native-query name="fetchIdAndUsernameWithResultClass" result-class="CmsUser">
<query>SELECT id, username FROM cms_users WHERE username = ?</query>
</named-native-query>
<named-native-query name="fetchAllColumns" result-class="CmsUser">
<query>SELECT * FROM cms_users WHERE username = ?</query>
</named-native-query>
@ -90,20 +90,7 @@
<field name="status" column="status" type="string" length="50" unique="true"/>
<field name="username" column="username" type="string" length="255" unique="true"/>
<field name="name" column="name" type="string" length="255"/>
<one-to-many field="phonenumbers" target-entity="CmsPhonenumber" mapped-by="user" orphan-removal="true">
<cascade>
<cascade-persist/>
<cascade-merge/>
</cascade>
</one-to-many>
<one-to-many field="articles" target-entity="CmsArticle" mapped-by="user">
<cascade>
<cascade-detach/>
</cascade>
</one-to-many>
<one-to-one field="address" target-entity="CmsAddress" inversed-by="user" orphan-removal="true">
<cascade>
<cascade-persist/>
@ -117,12 +104,25 @@
</cascade>
<join-column referenced-column-name="id" nullable="true" />
</one-to-one>
<one-to-many field="phonenumbers" target-entity="CmsPhonenumber" mapped-by="user" orphan-removal="true">
<cascade>
<cascade-persist/>
<cascade-merge/>
</cascade>
</one-to-many>
<one-to-many field="articles" target-entity="CmsArticle" mapped-by="user">
<cascade>
<cascade-detach/>
</cascade>
</one-to-many>
<many-to-many field="groups" target-entity="CmsGroup">
<cascade>
<cascade-persist/>
<cascade-detach/>
<cascade-merge/>
<cascade-detach/>
</cascade>
<join-table name="cms_users_groups">
<join-columns>
@ -133,7 +133,7 @@
</inverse-join-columns>
</join-table>
</many-to-many>
</entity>
</doctrine-mapping>

View File

@ -7,6 +7,12 @@
<entity name="Doctrine\Tests\Models\Company\CompanyPerson" table="company_persons" inheritance-type="JOINED">
<discriminator-map >
<discriminator-mapping value="person" class="CompanyPerson" />
<discriminator-mapping value="manager" class="CompanyManager" />
<discriminator-mapping value="employee" class="CompanyEmployee" />
</discriminator-map>
<named-native-queries>
<named-native-query name="fetchAllWithResultClass" result-class="__CLASS__">
<query>SELECT id, name, discr FROM company_persons ORDER BY name</query>
@ -26,12 +32,6 @@
</sql-result-set-mapping>
</sql-result-set-mappings>
<discriminator-map >
<discriminator-mapping value="person" class="CompanyPerson" />
<discriminator-mapping value="manager" class="CompanyManager" />
<discriminator-mapping value="employee" class="CompanyEmployee" />
</discriminator-map>
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>

View File

@ -5,18 +5,19 @@
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\Models\DDC117\DDC117Translation">
<many-to-one field="article" target-entity="DDC117Article">
<join-column name="article_id" referenced-column-name="article_id" />
</many-to-one>
<many-to-many field="reviewedByEditors" target-entity="DDC117Editor" mapped-by="reviewingTranslations" />
<one-to-many field="lastTranslatedBy" target-entity="DDC117Editor" mapped-by="lastTranslation" />
<id name="article" association-key="true" />
<id name="language" type="string" />
<field name="title" type="string" />
<one-to-many field="lastTranslatedBy" target-entity="DDC117Editor" mapped-by="lastTranslation" />
<many-to-one field="article" target-entity="DDC117Article">
<join-column name="article_id" referenced-column-name="article_id" />
</many-to-one>
<many-to-many field="reviewedByEditors" target-entity="DDC117Editor" mapped-by="reviewingTranslations" />
</entity>
</doctrine-mapping>

View File

@ -4,11 +4,11 @@
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\ORM\Mapping\Animal" inheritance-type="SINGLE_TABLE">
<discriminator-column name="discr" type="string" length="32" />
<discriminator-map>
<discriminator-mapping value="cat" class="Cat" />
<discriminator-mapping value="dog" class="Dog" />
</discriminator-map>
<discriminator-column name="discr" type="string" length="32" />
<id name="id" type="integer" column="id">
<generator strategy="CUSTOM" />
<custom-id-generator class="stdClass" />

View File

@ -5,16 +5,16 @@
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Doctrine\Tests\ORM\Mapping\DDC807Entity" inheritance-type="SINGLE_TABLE">
<id name="id">
<generator strategy="NONE"/>
</id>
<discriminator-column name="dtype" column-definition="ENUM('ONE','TWO')"/>
<discriminator-map>
<discriminator-mapping value="ONE" class="DDC807SubClasse1" />
<discriminator-mapping value="TWO" class="DDC807SubClasse1" />
</discriminator-map>
<id name="id">
<generator strategy="NONE"/>
</id>
</entity>
</doctrine-mapping>