eclipse 如何解决 jdoconfig.xml 中 xsi:noNamespaceSchemaLocation 上的验证错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12654503/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:05:37  来源:igfitidea点击:

How to solve validation error on xsi:noNamespaceSchemaLocation in jdoconfig.xml

eclipsegoogle-app-enginejdoxsd-validation

提问by mamuso

Since I updated today to GAE 1.7.2.1, I'm having validation errors in eclipse in all my jdoconfig.xml files.

自从我今天更新到 GAE 1.7.2.1 以来,我在 eclipse 中的所有 jdoconfig.xml 文件中都出现了验证错误。

I have the default jdoconfig.xml content :

我有默认的 jdoconfig.xml 内容:

[...]
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">
[...]

And eclipse validation throws:

和 Eclipse 验证抛出:

Referenced file contains errors (http://java.sun.com/xml/ns/jdo/jdoconfig).  
For more information, right click on the message in the Problems View and 
select "Show Details..."

When clicking on details I can see a bunch of lines like:

单击详细信息时,我可以看到一堆行,例如:

s4s-elt-character: Non-whitespace characters are not allowed in schema elements
other than 'xs:appinfo' and 'xs:documentation'. Saw 'var_U = "undefined";'.

In different lines and different content in "Saw ... "

在“Saw ...”的不同行和不同内容中

It occurs in every single project I start using the "New Web Application Project..." from the google plugin.

它发生在我开始使用 google 插件中的“新 Web 应用程序项目...”的每个项目中。

So does anyone have this problem? Any fix?

那么有人有这个问题吗?任何修复?

回答by joncalhoun

Try this:

尝试这个:

<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd">

Per the answer here Validating jdoconfig with incorrect url

根据此处的答案验证 jdoconfig 使用不正确的 url

The xmlns is not a real file/directory, more a namespace, so ought not exist! The version is appended to get the real XSD file, namely http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd

xmlns 不是一个真正的文件/目录,更像是一个命名空间,所以不应该存在!附加版本以获得真正的XSD文件,即http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd

回答by C. M. Sperberg-McQueen

There are a couple problems here.

这里有几个问题。

The syntactic problem is that the URI you are giving as the value of xsi:noNamespaceSchemaLocationis redirected to http://www.oracle.com/technetwork/java/index.htmland returns an HTML document. The XSD validator you are using is trying without success to parse

语法问题是您提供的 URI 作为 的值xsi:noNamespaceSchemaLocation被重定向到http://www.oracle.com/technetwork/java/index.html并返回一个 HTML 文档。您正在使用的 XSD 验证器正在尝试解析但没有成功

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" 
          content="text/html; charset=utf-8" />
    <script type="text/javascript">
      var _U = "undefined";
      var g_HttpRelativeWebRoot = "/ocom/";
      var SSContributor = false;
...

as an XSD schema document, and for one reason or another its attempts to explain what went wrong focus on finding the string var_U = "undefined"in a place where it was not expecting to see character data.

作为 XSD 模式文档,出于某种原因,它试图解释出了什么问题,重点var_U = "undefined"是在不希望看到字符数据的地方找到字符串。

Then there are some conceptual problems.

然后是一些概念上的问题。

  • Your document is in a namespace named http://java.sun.com/xml/ns/jdo/jdoconfig. Why on earth are you pointing the schema validator to a schema without a target namespace (which is that noNamespaceSchemaLocationdoes), if you want to validate your document? Given that (at least some of) your document's elements are namespace-qualified, you will want (as joncalhoun has already suggested) to use xsi:schemaLocationand provide a pairtelling the validator where it can find a schema document for each namespace you want it to know about.

  • It's possible that a schema document used to be served from the location http://java.sun.com/xml/ns/jdo/jdoconfig, but since it's apparently the standard namespace named for your vocabulary, that's not actually very likely. Most systems distinguish fairly reliably between namespaces, which are abstract and poorly defined things, and schema documents, which are typically XML documents that define specific XSD schema components for a given namespace. It's not illegal to use the URI for a schema document as the name of a namespace, but it is unusual.

  • 您的文档位于名为 的命名空间中http://java.sun.com/xml/ns/jdo/jdoconfignoNamespaceSchemaLocation如果您想验证您的文档,为什么要将架构验证器指向一个没有目标命名空间的架构(确实如此)?鉴于(至少部分)您的文档元素是命名空间限定的,您将希望(正如 joncalhoun 已经建议的那样)使用xsi:schemaLocation并提供一告诉验证器它可以在何处找到您希望它知道的每个命名空间的架构文档关于。

  • 可能曾经从 location 提供模式文档http://java.sun.com/xml/ns/jdo/jdoconfig,但由于它显然是为您的词汇表命名的标准命名空间,这实际上不太可能。大多数系统相当可靠地区分命名空间(抽象的和定义不明确的事物)和模式文档(通常是为给定命名空间定义特定 XSD 模式组件的 XML 文档)。将模式文档的 URI 用作命名空间的名称并不违法,但这种情况并不常见。

Note that the URL given by joncalhoun for the schema document (http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd) actually does resolve (after redirection to http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/jdo/jdoconfig_3_0.xsd) to a schema document, which specifies http://java.sun.com/xml/ns/jdo/jdoconfigas its target namespace. (This means that even if you did succeed in retrieving this schema document by giving its URI as the value of xsi:noNamespaceSchemaLocation, you'd then get an error because it's not a schema document for elements and attributes with no namespace.)

请注意,joncalhoun 为架构文档 ( http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd)提供的 URL实际上确实解析(在重定向到 之后http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/jdo/jdoconfig_3_0.xsd)到架构文档,该文档指定http://java.sun.com/xml/ns/jdo/jdoconfig为其目标命名空间。(这意味着即使您通过将其 URI 作为 的值确实成功检索了此架构文档xsi:noNamespaceSchemaLocation,您也会收到错误消息,因为它不是没有命名空间的元素和属性的架构文档。)

This makes me think that you should read joncalhoun's answer again and try it again, carefully. If it didn't work when you tried it, my money says that either you tried something similar but not exactly what he suggested, or it solved thisproblem but that simply exposed some otherproblem, which is easy to mistake for failure.

这让我觉得您应该再次阅读 joncalhoun 的答案,然后仔细再试一次。如果你试了没用,我的钱说,要么你尝试了类似但不完全符合他建议的东西,要么解决了这个问题但只是暴露了其他一些问题,这很容易误认为失败。

回答by ?ubomír Masarik

One solution is setting XML Catalog in Eclipse preferences.

一种解决方案是在 Eclipse 首选项中设置 XML Catalog。

Details:
Entry element: URI
Location: http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd
URI: http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd
Key type: Namespace name
Key: http://java.sun.com/xml/ns/jdo/jdoconfig

详细信息:
条目元素:URI
位置: http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd
URI: http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd
密钥类型:命名空间名称
密钥: http://java.sun.com/xml/ns/jdo/jdoconfig

回答by ?ubomír Masarik

The syntactic and conceptual issues C.M. mentions are a problem with the plugin and Google's settings where both recommend,

CM 提到的语法和概念问题是插件和谷歌设置的问题,两者都推荐,

xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig

I don't specifically use jdo but I still get the validation error with this namespace. It was fine with this namespace until just recently.

我没有专门使用 jdo,但我仍然收到此命名空间的验证错误。直到最近,这个命名空间都很好。

I used LuboM's method and it worked for me. Neither LuboM's nor joncalhoun's is the answer though since it ties me in to jdo 3.0

我使用了 LuboM 的方法,它对我有用。LuboM 和 joncalhoun 都不是答案,因为它将我与 jdo 3.0 联系起来

Oracle is going to have to provide the fix. Apparently their intent was to resolve the namespace issues themselves across versions of jdo.

Oracle 将不得不提供修复程序。显然,他们的目的是解决跨 jdo 版本的命名空间问题。

回答by user3631524

You might have try this path to solve your problem:

您可能已尝试此路径来解决您的问题:

<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">

回答by Simon

This is what I did to fix it:

这是我为修复它所做的:

<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig_3_0.xsd">

回答by Lev

I had the same issue, and excluded just this jdoconfig.xml file from Eclipse's validation. Even though your Eclipse throws an error for it, it in no way affects being able to deploy the project to GAE correctly.

我遇到了同样的问题,并从 Eclipse 的验证中排除了这个 jdoconfig.xml 文件。即使您的 Eclipse 为其抛出错误,它也不会影响将项目正确部署到 GAE 的能力。

Here is how to exclude just the jdoconfig.xml file to get rid of that pesky error:

以下是如何仅排除 jdoconfig.xml 文件以摆脱那个讨厌的错误:

Right click on your Eclipse Project, ->Properties->Validation->XML Validator, click on the "..." button for further options.

右键单击您的Eclipse Project, ->Properties->Validation->XML Validator,单击“...”按钮以获取更多选项。

You should see Include Group and Exclude Group options. Click Exclude Group->Add Rule...->Folder or file name, and browse to your file.

您应该看到包括组和排除组选项。单击排除组-> 添加规则...-> 文件夹或文件名,然后浏览到您的文件。

Clean or rebuild your project. The validation error should be gone.

清理或重建您的项目。验证错误应该消失了。

This worked for me in Eclipse Luna.

这在 Eclipse Luna 中对我有用。

回答by Prakash Ayappan

I am success on this:

我在这方面取得了成功:

Right Click Project -> Properties -> Validation -> XML Syntax
  1. Enable Project Specific Settings (If you need)
  2. Under Validating Files, For No grammar Specified Select "Warning"
  3. Click "Ok"
  4. If you ask for Validating the file, Click "Yes"
  1. 启用项目特定设置(如果需要)
  2. 在验证文件下,对于未指定语法,选择“警告”
  3. 点击“确定”
  4. 如果您要求验证文件,请单击“是”

You can do the same for all the projects by going to Windows -> Preferences.

您可以通过转到 对所有项目执行相同操作Windows -> Preferences

Make sure you are validating the file (Step 4).

确保您正在验证文件(步骤 4)。