Creating Vocabularies that Belong to a Namespace
File: Schema.xsd
<?xml version = "1.0" ?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema"
targetNamespace = "http://www.java2s.com/Customers"
xmlns = "http://www.java2s.com/Customers">
<xs:element name = "Customer" >
<xs:complexType>
<xs:sequence>
<xs:element name = "FirstName" type = "xs:string" />
<xs:element name = "MiddleInitial" type = "xs:string" />
<xs:element ref = "LastName" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = "LastName" type = "xs:string" />
</xs:schema>
File: Data.xml
<?xml version = "1.0" ?>
<cust:Customer xmlns:cust = "http://www.java2s.com/Customers"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "Schema.xsd">
<FirstName>first</FirstName>
<MiddleInitial>middle</MiddleInitial>
<cust:LastName>last</cust:LastName>
</cust:Customer>
Related examples in the same category