3

So before we write the XML Schema, a lot of tutorials use this:

 <?xml version='1.0'?>

or

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

My question is, what is this part for? What is that website specifically and why do we use it? Are there other methods to do this?

If it helps, I am doing this to convert an excel worksheet into XML.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
J.H
  • 181
  • 5
  • 14

3 Answers3

2

XML Declaration

<?xml version='1.0'?> is an XML declaration and is not particular to XSDs but to XML documents in general.

[Definition: XML documents should begin with an XML declaration which specifies the version of XML being used.]

As an XSD is an XML document, it may also have an XML declaration.

Here is the BNF of an XML declaration (XMLDecl) with links to the definitions of its constituent parts:

XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'

Note: Only one XML declaration is permitted in well-formed XML, and it must be at the top if anywhere. If you violate this requirement, you'll see an error such as

The processing instruction target matching "[xX][mM][lL]" is not allowed.

and you'll have to fix the problem before your XML will be well-formed.


XML Schema Instance Namespace

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" is a namespace declaration for the special XML Schema instance namespace. As a namespace URI, its purpose is to facilitate control of grouping of component name. An XML namespace URI does not have to be retrievable.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240
1

XML declaration. See https://www.w3.org/TR/2006/REC-xml-20060816/#sec-prolog-dtd for more information.

keshlam
  • 7,931
  • 2
  • 19
  • 33
0
<?xml version='1.0'?>

1.0 is the current version of XML. And the number might change for future versions. This is a mandatory field and it indicates which version of XML standard this file conforms to.

encoding="UTF-8"

This mean the file is encoded in UTF-8. This is optional since this is the default character encoding in XML.

standalone="yes"

standalone indicates whether if the current XML document depends on an external markup declaration. This is also optional.

<data-set xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

This is the XML Schema Instance namespace. After having this declared you can use attributes such as schemaLocation.

See similar answer: Is xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" a special case in XML?

Community
  • 1
  • 1
Ingako
  • 393
  • 4
  • 14