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.
<?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.
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
xsi
in particular. (xsi:type
, xsi:nil
, xsi:schemaLocation
, and xsi:noNamespaceSchemaLocation
)XML declaration. See https://www.w3.org/TR/2006/REC-xml-20060816/#sec-prolog-dtd for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With