XML / XSD publicId和systemId之间需要空格

时间:2013-04-24 19:11:57

标签: xml eclipse validation xsd doctrine

我在Eclipse中有一个包含大量XML文件的PHP项目。现在,我的所有XML文件都未通过验证,并显示以下错误消息:

White spaces are required between publicId and systemId

我一直在搜索,publicId和systemId似乎与以DOCTYPE开头的XML文件相关。我没有。另一个SO posting表示将XSD添加到Eclipse中的XML目录中,但这似乎没有什么区别。

以下是一个示例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://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Doctrine\Tests\Models\CMS\CmsAddress" table="cms_users">

        <named-native-queries>
            <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>

            <named-native-query name="count" result-set-mapping="mapping-count">
                <query>SELECT COUNT(*) AS count FROM cms_addresses</query>
            </named-native-query>
        </named-native-queries>

        <sql-result-set-mappings>
            <sql-result-set-mapping name="mapping-find-all">
                <entity-result entity-class="CmsAddress">
                    <field-result name="id" column="id"/>
                    <field-result name="city" column="city"/>
                    <field-result name="country" column="country"/>
                </entity-result>
            </sql-result-set-mapping>

            <sql-result-set-mapping name="mapping-without-fields">
                <entity-result entity-class="CmsAddress"/>
            </sql-result-set-mapping>

            <sql-result-set-mapping name="mapping-count">
                <column-result name="count"/>
            </sql-result-set-mapping>
        </sql-result-set-mappings>

        <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"/>

        <one-to-one field="user" target-entity="CmsUser" inversed-by="address">
            <join-column referenced-column-name="id" />
        </one-to-one>

    </entity>
</doctrine-mapping>

我有点难以接受下一步的尝试。我可以禁用XML验证,但我不喜欢这样做以解决Eclipse中的错误。如果它有任何区别,我正在使用带有PDT的Eclipse 3.7。失败的XML文件都是库的一部分,所以我认为它必须是一个必须修改/纠正以解决问题的Eclipse配置细节,但我不知道是什么。

我可以尝试让我的XML文件验证的任何建议吗?

2 个答案:

答案 0 :(得分:13)

基本上,订单应该是这样 - 属性,然后是property.xsd

def pet_list_parser(pets):
    if type(pets) != list:
        raise ValueError('Expected a list!')

    # Do your validation of the pet objects here. For example:
    for pet in pets:
        if 'name' not in pet:
            raise ValueError('Pet name is required')

        # Also do any conversion of data types here
        pet['name'] = pet['name'].capitalize()

    return pets

parser = RequestParser()
parser.add_argument('pets', type=pet_list_parser)

答案 1 :(得分:0)

保持空白&#34; &#34;在 xsi:schemaLocation 属性中的每个URL之后,除了最后一个。

xsi:schemaLocation =&#34; http://doctrine-project.org/schemas/orm/doctrine-mapping**< 1个空格&gt; ** http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd&#34;&gt; < / p>