Section 14.9. What are XML namespaces?


14.9. What are XML namespaces?

The fact that XML as a standard does not dictate semantics means that we can define any document structures we wish. I may decide on a certain structure for a purchase order, but if you decide on a different structure, we will need to translate each other's messages or else we will not be able to communicate.

The flexibility that XML provides by allowing us to create any tags we want can also lead to problems. An XML document can be constructed from multiple sources. Since these different sources may use tags with the same names, conflicts are possible. Consider the seemingly innocent tag, <Order_Number>. Do we mean the order number used when we purchased the item or the order number assigned when we sold the item? Without further definition, such a common term can be ambiguous. The basic solution to this problem is to use an XML technology known as namespaces.

We declare XML namespaces and then preface a tag with the namespace name. In this way, we remove all ambiguity about which tag we are using.

The schema in Example 14-1 uses namespaces. In the beginning of the file, we see the namespace declaration, using the xmlns element:

 <xsd:schema    targetNamespace="http://sap.com/demo/WS/GetAddress/prepared"    xmlns="http://sap.com/demo/WS/GetAddress/prepared"    xmlns:xsd="http://www.w3.org/2001/XMLSchema">




Enterprise SOA. Designing IT for Business Innovation
Enterprise SOA: Designing IT for Business Innovation
ISBN: 0596102380
EAN: 2147483647
Year: 2004
Pages: 265

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net