Adding Namespaces

Now that we've got all our data added to the document, it's time to segregate it into namespaces so we can work with it.

When it comes to namespaces, an element or attribute can find itself in three possible situations. The first is an explicit namespace, in which the namespace is declared and a prefix is used. In a situation such as this, our orderSystem document might look like Listing 6.13.

Listing 6.13. Explicit Namespace Declarations
 0:<?xml version="1.0" encoding="UTF-8"?> 1:<orderSystem> 2: <ord:orders xmlns:ord="http://www.nicholaschase.com/orders/"> 3: <ord:order order_id="To1010mC24980190282174342At"> 4: <ord:order_status>open</ord:order_status> 5: <ord:item product_id="RC2342"> 6: <ord:quantity>5</ord:quantity> 7: ...

Get XML and Java™ from scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.