简体   繁体   English

XSOM解析器getResult返回null

[英]XSOM parser getResult returning null

I am trying to parse a XSD file. 我正在尝试解析XSD文件。 The parser parse method doesn't give any Exception but when I use parser.getResult() , it returns null . 解析器的parse方法没有给出任何异常,但是当我使用parser.getResult() ,它返回null My XSD file have one Schema node in it. 我的XSD文件中有一个Schema节点。

XSOMParser parser = new XSOMParser();
parser.parse(new File(schemaPath));  //This runs fine
this.schemaSet = parser.getResult(); //here I get A null

Any ideas? 有任何想法吗?

The javadoc for XSOMParser::getResult() states that it'll return null if there was a parsing error. XSOMParser :: getResult()的Javadoc指出,如果存在解析错误,它将返回null。 If your schema only has <xsd:schema/> and you're getting null with your version of the parser, I would call it a bug in the implementation (an empty schema is a valid schema). 如果您的架构仅包含<xsd:schema />,而您的解析器版本却为空,那么我将其称为实现中的错误(空架构是有效架构)。 If not, then I would explicitly attach an error handler to make sure there aren't other issues at play. 如果没有,那么我将明确地附加一个错误处理程序,以确保没有其他问题在起作用。 Most likely there's something wrong with it. 最有可能是出问题了。

Try to validate your XSD file first, using some sort of XML Schema validating tool. 首先尝试使用某种XML模式验证工具来验证XSD文件。 If your schema references external schemas, make sure that you specify a system id if your external references use relative URIs. 如果您的架构引用了外部架构,请确保在您的外部引用使用相对URI的情况下指定系统ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM