eclipse publicId 和 systemId 之间需要 XML/XSD 空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16200291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XML/XSD White spaces are required between publicId and systemId
提问by Eric B.
I've got a PHP project in Eclipse with a lot of XML files. Right now, all my XML files are failing validation, with the following error message:
我在 Eclipse 中有一个包含大量 XML 文件的 PHP 项目。现在,我所有的 XML 文件都未通过验证,并显示以下错误消息:
White spaces are required between publicId and systemId
I've searched around, and publicId and systemId seem to be related to XML files that start with DOCTYPE. Mine don't. Another SO postingindicated to add the XSD to the XML catalog in Eclipse, but that doesn't seem to make a difference.
我搜索了一下,publicId 和 systemId 似乎与以 DOCTYPE 开头的 XML 文件有关。我的没有。另一个SO 发布表明将 XSD 添加到 Eclipse 中的 XML 目录,但这似乎没有什么区别。
One sample XML is the following:
一个示例 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>
I'm a bit stumped at what to try next. I can disable XML validation, but I hate doing things like that to resolve errors in Eclipse. If it makes any difference, I'm using Eclipse 3.7 with PDT. The XML files that fail are all part of libraries so I presume it must be an Eclipse configuration detail that had to be modified/rectified to resolve the issue, but I have no idea what.
我对下一步该尝试什么感到有些困惑。我可以禁用 XML 验证,但我讨厌这样做来解决 Eclipse 中的错误。如果它有任何区别,我将使用带有 PDT 的 Eclipse 3.7。失败的 XML 文件都是库的一部分,所以我认为它必须是 Eclipse 配置细节,必须修改/纠正才能解决问题,但我不知道是什么。
Any suggestions what I can try to have my XML files validate?
我可以尝试验证我的 XML 文件的任何建议?
回答by Vardhini
Basically, the order should be like this - property and then followed by property.xsd
基本上,顺序应该是这样的 - 属性然后是property.xsd
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
回答by swateek
Maintain a blank space " " after each URL in the xsi:schemaLocationproperty except the last one.
在xsi:schemaLocation属性中的每个 URL 之后保留一个空格“”, 除了最后一个。
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping**<1 blank space>**http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping**<1 个空格>** http://www.doctrine-project.org/schemas/orm/doctrine-mapping .xsd">