Library tutorials & articles
XSD Schemas for VB Developers
- Why Schemas?
- Validating with Schema
- Authoring XSD Schemas
- Mapping VB Types to XSD
- Tighter Validation
- Schemas and Namespaces
- Summary
Authoring XSD Schemas
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<!-- schema content goes here -->
</schema>
The XSD namespace has changed quite a bit as the XSD specification itself has evolved. In the final specification, the XSD namespace is http://www.w3.org/2001/XMLSchema. If you come across an XSD schema that’s using a different namspace, you’ll know it’s written to an older (possibly draft) version of the XSD standard.
Within a schema, you define data types and declare elements. For example, assume you have this simple XML document:
<top>
<child1>text</child1>
<child2>text</child2>
</top>
The schema would first define a type that describes the contents of the <top> element. It would then declare and element of that type:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name=" topType">
<xsd:sequence>
<xsd:element name="child1" type="xsd:string"/>
<xsd:element name="child2" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name=" top" type=" topType"/>
</schema>
<xsd:complexType> defines a data type that contains child
elements and/or attributes. The <top> element contains child
element so it must be a complexType. Within this complex type, we specify that
there will be a sequence of child1 and child2 elements. <xsd:sequence>
means the elements must appear in that order, so if the XML document had <child2>
first then <child1> that would violate the sequence and would
be a validation error. Using <xsd:element> we declare each
of the <child1> and <child2> elements and
specify their data type as xsd:string. Note the use of the xsd: namespace prefix
to indicate that this is one of the XSD built-in data types.
Now that we have defined the data type that describes our <top>
element, we can declare the element itself using <xsd:element>.
Note that we specify its type as topType which is the name we used for the complexType.
The basics of creating XSD schemas are: First define your data types then declare elements of those types. Lets take a look at some real-world examples.
Related articles
Related discussion
-
handling special character in xslt's
by bussureddy82 (1 replies)
-
Need help in parsing a big XML file with JAVA
by praveen_a_p (0 replies)
-
XML WITH JAVA
by suzan4love (3 replies)
-
A simple way to read an XML file in Java
by ayf (32 replies)
-
how to bind the XML data to the textboxes
by Slicksim (1 replies)
Related podcasts
-
Java Posse #202 - Newscast for Aug 22nd 2008
Newcast for August 22nd, 2008Fully formatted shownotes can always be found at http://javaposse.com Sadly, Java does not run on the Mars LanderThe Golden Gate Project http://research.sun.com/projects/goldengate/Space surveillance radar http://www.sun.com/aboutsun/pr/2008-04/sunflash Google has r...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Trainer JAVA
in AMSTERDAM (€50K-€90K per annum) -
Applicatie ontwikkelaar binnen Defensie
in Amsterdam (£50K-£90K per annum) -
Ervaren SAP XI Specialist
in Amsterdam (€50K-€90K per annum)
This thread is for discussions of XSD Schemas for VB Developers.