Java XML Schema validation: prefix not bound

后端 未结 2 804
心在旅途
心在旅途 2020-12-16 02:16

I have followed this tutorial for validating XML files. But I am receiving exception when validating XML file. What I am doing wrong? My codes:
XML schema:



        
相关标签:
2条回答
  • 2020-12-16 02:51

    Add this line to your schema, just below the first line:

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    

    ... and a closing tag as the last line in the schema:

    </xs:schema>
    
    0 讨论(0)
  • 2020-12-16 03:13

    The XML schema file itself needs to be a valid XML document. You are missing the outer schema element and the namespace declaration for the xs prefix.

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <!-- schema elements here -->
    </xs:schema>
    
    0 讨论(0)
提交回复
热议问题