Defining Namespaces

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  XMLSpy Tutorial > XML Schemas: Basics >

Defining Namespaces

XML namespaces are an important issue in XML Schemas and XML documents. An XML Schema document must reference the XML Schema namespace and, optionally, it can define a target namespace for the XML document instance. As the schema designer, you must decide how to define both these namespaces (essentially, with what prefixes.)

 

In the XML Schema you are creating, you will define a target namespace for XML document instances. (The required reference to the XML Schema namespace is created automatically by XMLSpy when you create a new XML Schema document.)

 

To create a target namespace:

 

1.Select the menu option Schema Design | Schema settings. This opens the Schema Settings dialog.

tut_6a

2.Click the Target Namespace radio button, and enter http://my-company.com/namespace. In XMLSpy, the namespace you enter as the target namespace is created as the default namespace of the XML Schema document and displayed in the list of namespaces in the bottom pane of the dialog.
3.Confirm with the OK button.

 

Note the following:

 

The XML Schema namespace is automatically created by XMLSpy and given a prefix of xs:.
When the XML document instance is created, it must have the target namespace defined in the XML Schema for the XML document to be valid.

 


© 2019 Altova GmbH