2013-08-19 29 views
0

我想使用XML模式创建Java bean。我尝试使用freeformatter.com's XSD/XML Schema Generator从XML创建XML模式。这是XML模式,我已经产生和正在产生的错误:生成的xml模式显示错误

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://open-services.net/ns/core#" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="shortTitle"> 
    <xs:complexType> 
     <xs:simpleContent> 
     <xs:extension base="xs:string"> 
      <xs:attribute ref="rdf:parseType" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> 
     </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
    </xs:element> 
    <xs:element name="discussedBy"> 
    <xs:complexType> 
     <xs:simpleContent> 
     <xs:extension base="xs:string"> 
      <xs:attribute ref="rdf:resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> 
     </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
    </xs:element> 
    <xs:element name="instanceShape"> 
    <xs:complexType> 
     <xs:simpleContent> 
     <xs:extension base="xs:string"> 
      <xs:attribute ref="rdf:resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> 
     </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
    </xs:element> 
    <xs:element name="serviceProvider"> 
    <xs:complexType> 
     <xs:simpleContent> 
     <xs:extension base="xs:string"> 
      <xs:attribute ref="rdf:resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/> 
     </xs:extension> 
     </xs:simpleContent> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

这是错误:

- src-resolve.4.2: Error resolving component 'rdf:parseType'. It was detected that 'rdf:parseType' is in namespace 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', but 
    components from this namespace are not referenceable from schema document 'file:///home/workspace/jaxbexe/xsdfile.xsd'. If this is the incorrect namespace, 
    perhaps the prefix of 'rdf:parseType' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///home/ 
    workspace/jaxbexe/xsdfile.xsd'. 
    - s4s-elt-invalid-content.1: The content of '#AnonType_shortTitle' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often. 

回答

0

是的,这个免费的工具似乎是无法应付的命名空间。所以要么向作者投诉,要么修复,要么使用其他工具 - 周围有很多。

+0

我对这个工具并不熟悉。这个问题是否可以通过错误消息中的说明来解决:“如果这是正确的命名空间,那么应该在'file:///home/workspace/jaxbexe/xsdfile.xsd'中添加适当的'import'标记。”如果不是的话,错误信息是否会提出不恰当的建议? –

+0

是的,您当然可以尝试修复生成的XML,并且添加导入声明将成为该过程的一部分。但是我不知道是否只需要这么做:该工具是否为RDF名称空间生成了一个可导入的模式文档? –