How does XML Schema declarations work and refer to each other?

arifrhb

New Member
There is something fundemental I don't understand about Xml Schema declarations. I have the following declaration in an .xsd file:\[code\]<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="tile"> <xs:restriction base="xs:string"> <xs:pattern value="http://stackoverflow.com/questions/10433400/[a-z][0-9]"/> </xs:restriction> </xs:simpleType> <xs:element name="move"> <xs:complexType> <xs:sequence> <xs:element name="T" type="tile" /> </xs:sequence> </xs:complexType> </xs:element></xs:schema>\[/code\]So, for example \[code\]<move><T>a0</T><T>v5</T></move>\[/code\] should be a valid XML element according to the xsd file. (I've simplified the actual declaration, so the move may not make sense)Background: I am developing a project in C# 4.0. I use this xsd file as a project source. When I receive an XElement from somewhere, I first check whether it is valid according to the xsd above. The C# code works OK.Here is my question (hopefully a single question, asked three times):1) I want to put my declarations on a domain. Let's say \[code\]aliferhat.com\[/code\]. Or do I want to? Why should I want to do that? How can I do that? How can I use that declaration later from somewhere else?2) I will have many similar xsd files. Most of them will use the "tile" definition, so I want to put the part "tile" on a seperate file, and refer to that file from other xsd files. How can I do that? How will the system know where to look for definitions? 3) This is what the visual studio generates when I add a new XSD file to the project:\[code\]<xs:schema id="temp" targetNamespace="http://tempuri.org/temp.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/temp.xsd" xmlns:mstns="http://tempuri.org/temp.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"></xs:schema>\[/code\]What does \[code\]xmlns:xs\[/code\] and \[code\]targetNamespace\[/code\] attributes do? Are \[code\]xs:element\[/code\] and the rest really defined in one of these URIs? Do the C# compiler really look up those URIs for the definitions? I hope and guess I have asked only one question. I've read the "XML schema definition" page on W3 schools but could not find the answer. Any help will be appreciated.
 
Back
Top