0 votes

When running xmllint against the generated schema there are several validation errors:

Skipper v3.2.32.1734
Doctrine ORM v2.8.5

Running

xmllint --noout --schema vendor/doctrine/orm/doctrine-mapping.xsd data/orm/Money.Money.dcm.xml

with the generated schema (data/orm/Money.Money.dcm.xml):

<?xml version="1.0"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <embeddable name="Money\Money" class-type="embeddable">
    <field name="amount" type="bigint" nullable="false"/>
    <field name="currency" type="currency" nullable="false"/>
  </embeddable>
</doctrine-mapping>

Gives the following errors:

data/orm/Money.Money.dcm.xml:2: element doctrine-mapping: Schemas validity error : Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}doctrine-mapping', attribute 'xsi': The attribute 'xsi' is not allowed.
data/orm/Money.Money.dcm.xml:2: element doctrine-mapping: Schemas validity error : Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}doctrine-mapping', attribute 'schemaLocation': The attribute 'schemaLocation' is not allowed.
data/orm/Money.Money.dcm.xml:3: element embeddable: Schemas validity error : Element '{http://doctrine-project.org/schemas/orm/doctrine-mapping}embeddable', attribute 'class-type': The attribute 'class-type' is not allowed.
data/orm/Money.Money.dcm.xml fails to validate
warning: failed to load external entity "2"

The corrected XML validates:

<?xml version="1.0"?>
<doctrine-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                          https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <embeddable name="Money\Money">
        <field name="amount" type="bigint" nullable="false"/>
        <field name="currency" type="currency" nullable="false"/>
   </embeddable>
</doctrine-mapping>

The formatting I can deal with, but is there any way to remove/correct the invalid attributes and update to the correct XML header?

in Solved by (730 points)
recategorized by

Hello Ise,

thanks for the info, we will fix that.

Hello Ise,

Do you have any idea why XSD schema located on https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd doesn't work with xmllint (and any other schema validator?)

xmllint --noout --schema doctrine-mapping.xsd  test.xml
The XML document 'doctrine-mapping.XSD is not a schema document.
WXS schema doctrine-mapping.xsd failed to compile

I also tried to find another source for doctrine-mapping.xsd file but without success. I found only some old versions which contains a lot of false positives for valid XML files (for example invalid order of inner elements in entity tag.

Thanks for reply

I probably solved it, but I don't understand that.

When I change the header of xsd schema from this one

<xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
xmlns:orm="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
elementFormDefault="qualified">

to this one

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:orm="http://doctrine-project.org/schemas/orm/doctrine-mapping"
elementFormDefault="qualified">

xmlling begins to work as expected. So probably some https issue.

We will try to integrate xsd validation to our unit tests, so we can test all of 1000+ doctrine samples against xsd schema to ensure that everything is ok.

I will let you know.

It seems that also https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd XSD document isn't in sync with the latest features of the Doctrine2.

This makes a whole validation almost impossible.

For example, cascade element for associations can contain following values:

  <cascade-persist />
  <cascade-merge />
  <cascade-remove />
  <cascade-refresh />

https://www.doctrine-project.org/projects/doctrine-orm/en/latest/reference/xml-mapping.html#cascade-element

but XSD schema contains only following rules:

<xs:complexType name="cascade-type">
   <xs:choice minOccurs="0" maxOccurs="unbounded">
     <xs:element name="cascade-all" type="orm:emptyType" minOccurs="0"/>
     <xs:element name="cascade-persist" 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:choice>

som cascade-merge is invalid value by XSD schema but valid by documentation. This unfortunately makes a whole validation almost useless.....

1 Answer

0 votes
Best answer

Hi,

we just released a new beta that contains as many XSD fixes as possible.

https://www.skipper18.com/support/402/downloads-skipper-beta

As I wrote before, unfortunately, there are some areas where XSD isn't in sync with documentation. So in these cases, it will be necessary to report it to the Doctrine team for fix.

Please try it and let me know in case you will find any other inconsistencies. But all our unit tests are now passing (after removing cascade-merge for example).

by Skipper developer (138k points)
selected by

Unfortunately the same as my previous reply. This is the bug in the XSD schema supplied by Doctrine.

Schema available on the official https address doesn't define the order of elements.

Thanks I'll report this to doctrine/orm and fix them manually for now.

There was another issue in a client application where I can't share the XML, but I'm happy to accept this as my issue.

A discriminator-mapping element is being generated for an abstract entity which uses class-table-inheritance. With the value for this base class empty, the fully qualified class name is being used which throws an error.

With that, I've tested everything we have against the latest beta, and it all looks good to me! Thanks again for the fast turn around.

Thanks I'll report this to doctrine/orm and fix them manually for now.

You're welcome. I believe there is no real reason to force explicit XML elements order, so I think XSD file distributed with Doctrine is outdated and XSD file available on the web is latest.

A discriminator-mapping element is being generated for an abstract entity which uses class-table-inheritance. With the value for this base class empty, the fully qualified class name is being used which throws an error.

Would be possible to create some minimal test case and send this to me? Or maybe create copy of your client project, erase all other entities and rename remaining so you can share it?

You're welcome. I believe there is no real reason to force explicit XML elements order, so I think XSD file distributed with Doctrine is outdated and XSD file available on the web is latest.

It appears to be the reverse and that the one on the web is out of date. I think you are correct in using it though as it is unversioned so I'm not sure what else you could do without forcing a Doctrine ORM version on your customers. Here is the open issue I have with them:
https://github.com/doctrine/doctrine-website/issues/405.

Would be possible to create some minimal test case and send this to me? Or maybe create copy of your client project, erase all other entities and rename remaining so you can share it?

I'll see if I can create a minimal reproducible test case and get it to you.

Thanks for the update.

Unfortunately, this means that there are few more issues. Order of elements is forced on several other places and also there was some missing definition.

For now, we would wait until they sync the web version and bundled version. We need to know what is the correct final state and after that, we will continue to work on it. Please let me know when they merge it.

Thanks