Hello everyone,
I am a newbee in XML, and have a problem in XML schema. First I am writing an example from "Beginning XML" from Wrox.
**---------------- name5.xsd ----------------**
Code:
<?xml version="1.0" ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:target="http://www.example.com/name"
targetNameSpace="http://www.example.com/name" elementFormDefault="qualified"> /* ******* Problem 1 ******* */
<element name="name">
<complexType>
<sequence>
<element name="first" type="string" /> /* ******* Problem 2 ******** */
<element name="second" type="string" />
<element name="third" type="string" />
</sequence>
<attribute name="title" type="string" />
</complexType>
</element>
</schema>
**---------------- name5.xml ----------------**
Code:
<?xml version="1.0" ?>
<name xmlns="http://www.example.com/name" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com/name name5.xsd" title="Mr."> /* ******* Problem 3 ******** */
<first>John</first>
<middle>Fotzgerald Johansen</middle>
<last>Doe</last>
</name>
**--------------------------------------------------------------**
Problems:
Problem 1: Why is root element named - "schema", and not something else? And, if the URI in the namespace should be unique (I mean, they don't point to any URL or address; they are just unique name), why are we only using - xmlns="http://www.w3.org/2001/XMLSchema"?
Problem 2: type="string". The book says "string" is a datatype. Now type - "http://www.w3.org/2001/XMLSchema\third:string" is again only a unique name (it is not pointing to any URL); so where is the definition of primitive datatype. And if parser knows the definition, then why can't be it "target:string"
Problem 3: What is "xsi:schemaLocation". How does parser know, it can take namespace-location pair
Extra Problem: This one is hard to explain.
<complextype name="nameType">
....content model....
</complexType>
<element name="name" type="target:nameType" />
Now name="nameType" and ' type="target:nameType" ' belongs to different namespaces, then what does "target:nameType" point to ?
Thanks in advance.