2

私のXML

<?xml version="1.0" encoding="utf-8"?>
<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
                    http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="Entities\Aplikasi" table="aplikasi">
        <field name="nama" type="string" column="nama" length="20" precision="0" scale="0" unique="1"/>
        <id name="id" type="integer" column="id">
            <generator strategy="AUTO"/>
        </id>
    </entity>
</doctrine-mapping>

Netbeans で検証しようとすると、この結果が得られます

XML validation started.
Checking file:/home/meh/doctrine2/Entities/Mappings/Entities.Apliksi.dcm.xml...
cvc-elt.1: Cannot find the declaration of element 'doctrine-mapping'. [5] 
XML validation finished.

また、 http: //www.validome.org/xml/validate/ で XML を検証できませんでした。

有効であることを確認するにはどうすればよいですか?

4

2 に答える 2

1

XML を検証するために、いくつかの変更を加える必要がありました。

<?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://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <entity name="EntitiesAplikasi" table="aplikasi">
        <id name="id" type="integer" column="id">
            <generator strategy="AUTO"/>
        </id>

        <field name="nama" type="string" column="nama" length="20" unique="1"/>
   </entity>
</doctrine-mapping>

前にプレフィックスとxmlns前にプレフィックスを追加する必要があり、 id をフィールドの上に移動し、精度とスケールの属性を削除しました。xsixsischemaLocation

Web ブラウザーでスキーマに移動し、ソースの表示を選択するか、ダウンロードするだけで、スキーマを読み取って、有効な XML がどのように見えるかを判断できます。

于 2010-11-27T05:54:58.870 に答える
1

The same problem occurs while using Netbeans to validate any XML Schema (a XSD file, like any-xml-schema-name.xsd).


Before using your solution, my code was:

<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema" 

but it always fails to validate, with error message: "Cannot find the declaration of element 'xs:schema'"


Now, using your solution, I just changed the same code from above to:

<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema http://www.w3.org/2001/XMLSchema.xsd"

and it is working.


Thanks!
Marcio Wesley Borges
http://marciowb.info

于 2011-11-17T18:02:09.380 に答える