模式有效性错误:元素没有匹配的全局声明可用于验证根

5

我正在为XML创建一个XSD用于验证,但它给我返回以下验证错误:

$ xmllint --noout --schema imoveis.xsd imoveis.xml 
imoveis.xml:2: element alugueis: Schemas validity error : Element '{http://www.w3.org/2001/XMLSchema-instance}alugueis': No matching global declaration available for the validation root.
imoveis.xml fails to validate

我不确定自己忘了什么。

以下是我的XML代码:

<alugueis xmlns="http://www.w3.org/2001/XMLSchema-instance"
          noNamespaceSchemaLocation="imoveis.xsd"
          mes="outubro" ano="2012">

在这里是我的验证XSD

https://gist.github.com/paulodiovani/eb287e24de7be99a2263

<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="simulado"
        xmlns:doc="simulado"
        elementFormDefault="qualified">

https://gist.github.com/paulodiovani/b00c682cdd4d8e1b8d7f

1个回答

3

请按照以下方式修复您的XML:

<alugueis xmlns="simulado"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="simulado imoveis.xsd"
          mes="outubro" ano="2012">

你的XSD应该能够被找到。你可能还需要进行一些修正(例如condominio),但这些应该是不言自明的。如果还有疑问,请随时再次发布。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接