Research, training, consultancy and software to reduce IT costs | |||||
Minimal integration 5: keep XML simpleExtensible markup language (XML) is ideal as an interface data format. To keep it simple, you need to adopt some simple rules which ignore many of its advanced features. XML is really very simple. The basic unit of XML is called an element. Every element has a name, and some content, and is coded like this: <MyElementName> ... any content you like ... </MyElementName> The content can be data, in which case we can call the element a "data element". Alternatively, the content can be other elements. We can then call the element a "structural element". In the example below, the elements Order, OrderItemList and OrderItem are structural elements, and the elements customerName, productNumber and quantity are data elements. <Order> <customerName>Mr J Smith</customerName> <OrderItemList> <OrderItem> <productNumber>018716</productNumber> <quantity>2</quantity> </OrderItem> <OrderItem> <productNumber>907232</productNumber> <quantity>1</quantity> </OrderItem> </OrderItemList> </Order> The rules for keeping XML simple are also very simple.
These rules make sure that the XML is always easy to understand. They also make sure that the XML is easy to convert to other structures such as objects in a programming language or data on a database. If you see other examples of XML, they probably will not meet these rules, and may contain more advanced features. <?xml version="1.0" encoding="UTF-8"?> <!-- Sample order file --> <Envelope xmlns:order="http://minimalit.com/order.xsd"> <order:Order order_ref="103820"> <order:customerName>Mr J Smith</order:customerName> <order:address> 14 Acacia Avenue Twickenham <order:postcode>TR7 4BU</order:postcode> </order:address> <order:OrderItem quantity="2">018716</order:OrderItem> <order:OrderItem quantity="1">907232</order:OrderItem> </order:Order> </Envelope> It is useful to be able to read XML like this. The main features you will come across are:
I have written hundreds of XML interface definitions, and I rarely need to use any of these other features. Learn to read them, but only use them where there is a real need. Having covered how to format data sent between systems, next week I will cover some of the technologies that we can use to actually send the data. Next: Minimal integration 6: standardise data transferSubscription |
Latest newsletter: |
||||
Copyright © 2005-2015 Minimal IT Ltd. All rights reserved. Minimal IT: research, training, consultancy and software to reduce IT costs.
|