What is the purpose of XSD files?

前端 未结 10 1479
抹茶落季
抹茶落季 2020-11-30 20:25

Since we can query on the XML file from C# (.NET), why do we need an XSD file? I know it is metadata file of particular XML file. We can specify the relationships in XSD, b

相关标签:
10条回答
  • 2020-11-30 21:10

    An .xsd file is called an XML schema. Via an XML schema, we may require a certain structure in a given XML - which elements in which order, how many times, with which attributes, how they are nested, etc. If we have a schema for our XML input, we can verify that it contains the data we need it to contain, and nothing else, with a few lines invoking a schema validator.

    0 讨论(0)
  • 2020-11-30 21:21

    The xsd file is the schema of the xml file - it defines which elements may occur and their restrictions (like amount, order, boundaries, relationships,...)

    0 讨论(0)
  • 2020-11-30 21:24

    You mention C# in your question so it may help to think of as XSD as serving a similar role to a C# interface.

    It defines what the XML should 'look like' in a similar way that an interface defines what a class should implement.

    0 讨论(0)
  • 2020-11-30 21:25

    Before understanding the XSD(XML Schema Definition) let me explain;

    What is schema?

    for example; emailID: peter#gmail

    You can identify the above emailID is not valid because there is no @, .com or .net or .org.

    We know the email schema it looks like peter@gmail.com.

    Conclusion: Schema does not validate the data, It does the validation of structure.

    XSD is actually one of the implementation of XML Schema. others we have relaxng

    We use XSD to validate XML data.

    0 讨论(0)
提交回复
热议问题