模式不能包含两个具有相同名称的全局组件

时间:2016-07-27 14:16:31

标签: java xml spring

我收到此错误

Referenced file contains errors (project-aware://go-ontology/org/springframework/beans/factory/xml/spring-beans-3.1.xsd).  For more information, right click on the message in the Problems View and select "Show Details..."   gorules-ontology-beans.xml  /go-ontology/src/main/resources line 1  XML Problem

当我查看“更多详情”时,它会给我以下内容:

The errors below were detected when validating the file "spring-beans-3.1.xsd" via the file "gorules-ontology-beans.xml".  In most cases these errors can be detected by validating "spring-beans-3.1.xsd" directly.  However it is possible that errors will only occur when spring-beans-3.1.xsd is validated in the context of gorules-ontology-beans.xml.


    sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/beans,identifiedType'.

gorules-ontology-beans.xml

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
    ">

    <neo4j:repositories base-package="pl.polsl.lstypka.gorules.ontology.reporitory" />

</beans>

我在java方面不是很好,我找到了一些解决方案,但它没有用。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

以下是使用Saxon运行此验证时发生的情况(使用命令行-t选项生成输出):

Saxon-EE 9.7.0.7J from Saxonica
Java version 1.6.0_27
Using license serial number V000006
Schema checking successful. Time: 0ms. Memory: 3Mb.
Using parser org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser
Processing file:/Users/mike/Desktop/temp/test.xml
URIResolver.resolve href="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" base="file:/Users/mike/Desktop/temp/test.xml"
Loading schema document http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
Finished loading schema document http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
URIResolver.resolve href="http://www.springframework.org/schema/context/spring-context-3.0.xsd" base="file:/Users/mike/Desktop/temp/test.xml"
Loading schema document http://www.springframework.org/schema/context/spring-context-3.0.xsd
Warning at xsd:import on line 11 column 153 of spring-context-3.0.xsd:
  The schema document at http://www.springframework.org/schema/beans/spring-beans-3.0.xsd is
  not being read because schema components for this namespace are already available. To
  force the schema document to be read, set --multipleSchemaImports:on
URIResolver.resolve href="http://www.springframework.org/schema/tool/spring-tool-3.0.xsd" base="http://www.springframework.org/schema/context/spring-context-3.0.xsd"
Loading schema document http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
Finished loading schema document http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
Finished loading schema document http://www.springframework.org/schema/context/spring-context-3.0.xsd
URIResolver.resolve href="http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd" base="file:/Users/mike/Desktop/temp/test.xml"
Loading schema document http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
URIResolver.resolve href="http://www.springframework.org/schema/data/repository/spring-repository-1.0.xsd" base="http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd"
Loading schema document http://www.springframework.org/schema/data/repository/spring-repository-1.0.xsd
Warning at xsd:import on line 11 column 87 of spring-repository-1.0.xsd:
  The schema document at http://www.springframework.org/schema/context/spring-context.xsd is
  not being read because schema components for this namespace are already available. To
  force the schema document to be read, set --multipleSchemaImports:on
Finished loading schema document http://www.springframework.org/schema/data/repository/spring-repository-1.0.xsd
Finished loading schema document http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
Validation time: 368ms. Memory: 15Mb.
Validation successful

这些警告说的是,在模式文档层次结构中的某个地方有两个对具有相同命名空间的模式的引用(它可能与引用的实际模式文档相同或不同,引用可能是也可能不是相同的实际网址)。 Saxon猜测第二个引用可以被忽略,因为它可能是相同的模式文档,并且在这种情况下,似乎Saxon已经猜对了,因为不同的处理器(你的)采取了不同的决定,遵循两个引用,并结束结果是同一组件的多个定义。