本文介绍了XJC多个XSD - >使用“剧集”的类生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个最简单的xsd文件。
I have two most simple xsd files.
a.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:a="A" targetNamespace="A">
<complexType name="myType"/>
<element name="root" type="a:myType"/>
</schema>
b.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="B" xmlns:a="A">
<import namespace="A"/>
<complexType name="extendedType">
<complexContent>
<extension base="a:myType"/>
</complexContent>
</complexType>
</schema>
我们在b.xsd中使用 myType
它在a.xsd中定义。生成过程包括使用剧集功能的两个步骤。
We use the myType
in b.xsd which is defined in a.xsd. The generation process consists of two steps using the "episode" feature.
> xjc -episode a.episode a.xsd
parsing a schema...
compiling a schema...
a\MyType.java
a\ObjectFactory.java
a\package-info.java
> xjc b.xsd -b a.episode
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'a:myType' to a(n) 'type definition' component.
line 7 of file:/b.xsd
Failed to parse a schema.
第一代使用有效的a.episode文件成功,但第二代失败。这里有什么问题?
The first generation succeeds with a valid a.episode file, but the second fails. What is wrong here?
推荐答案
我用Apache XMLBeans 2.5.0尝试了你的例子,它使用了这个命令:
I tried your example with Apache XMLBeans 2.5.0 and it worked with this command:
scomp -srconly a.xsd b.xsd
这篇关于XJC多个XSD - >使用“剧集”的类生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!