cvc-elt.1: Cannot find the declaration of element 'MyElement'

后端 未结 3 1109
小蘑菇
小蘑菇 2020-12-01 07:42

I\'m trying to validate a really simple xml using xsd, but for some reason I get this error. I\'ll really appreciate if someone can explain me why.

XML File

3条回答
  •  执笔经年
    2020-12-01 07:49

    Your schema is for its target namespace http://www.example.org/Test so it defines an element with name MyElement in that target namespace http://www.example.org/Test. Your instance document however has an element with name MyElement in no namespace. That is why the validating parser tells you it can't find a declaration for that element, you haven't provided a schema for elements in no namespace.

    You either need to change the schema to not use a target namespace at all or you need to change the instance to use e.g. A.

提交回复
热议问题