gpt4 book ai didi

java - 显示 org.eclipse.xsd.XSDSchema 内容

转载 作者:太空宇宙 更新时间:2023-11-04 08:09:24 25 4
gpt4 key购买 nike

我有简单的 xsd 文件:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

以及一些解析它的代码

String aFile = "C:\\1.xsd";
XSDParser parser=null;
XSDSchema schema;
URI schemaUri = new File(aFile).toURI();
String uri;
try {
uri = schemaUri.toURL().toString();
parser=XSDParser.class.newInstance();
parser.parse(uri);
schema = parser.getSchema();
for (XSDElementDeclaration element : schema.getElementDeclarations()) {
System.out.println(element.getName());
}

程序打印“note”。我调试了它,找不到元素到、来自、标题和正文。我需要更改什么才能接收输出:

note
to
from
heading
body

最佳答案

org.eclipse.xsd.util.XSDPrototypicalSchema

构建实例可能会帮助您了解如何遍历它们。

关于java - 显示 org.eclipse.xsd.XSDSchema 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11493411/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com