XSD错误:元素或属性与QName生成不匹配:QName :: =(NCName':')?NCName

时间:2014-04-02 11:38:04

标签: xml web-services xml-parsing xsd xsd-validation

这是我试图从WSDL文件制作的XSD: 为什么我要这么做?  我想从WSDL中提取内联模式 并将它们放在XSD文件中, 接下来,我将捕获Request XML Payload和  然后使用我的XSD验证代码来验证针对此XSD的Request XML。 在我的验证步骤之前,由于下面提到的解析异常,这会失败:

Getting an exception at Line 2,3

详细例外:

Exception: Element or attribute do not match QName production: QName::=(NCName':')?NCName. 
    org.xml.sax.SAXParseException; systemId: file:/D:/Test3/Inline_xsd.xsd; lineNumber: 3; columnNumber: 23; Element or attribute do not match QName production: QName::=(NCName':')?NCName. 
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLEntityScanner.scanQName(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
        at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
        at org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(Unknown Source)
        at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
        at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
        at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
        at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
        at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:591)
        at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:607)
        a

请原谅我只发布XSD的必要部分。

1 个答案:

答案 0 :(得分:2)

您错过了特殊前缀声明属性的实际名称。

xmlns:=应为xmlns:something=(紧跟版本属性后)

我会删除这个错误构造的属性;看来你的XSD中不需要这个别名,因为它指向WSDL名称空间。