Namespaces and Includes

When working with XML and XML Schemas, Namespaces makes it a bit difficult. The main issue with Namespaces in my opinion is the difficulty in dealing with the prefix to the namespace uri mapping. The software used to generate Visual Schemas has been tested with several different standards (as can be seen from this blog history), yet, very rarely some issues are identified in the software. As part of generating the Visual Schemas for Election Markup Language (EML), two additional issues were uncovered. One was an issue where the name of the element instead of the qname was used and it’s a outright implementation bug. However, the other one was more interesting.

EML schemas include additional schemas (core and external) and these included schemas include a few more schemas that have their own namespaces. The current Visual Schema software implementation computed the namespace prefix to uri mapping based only on the outer most schema. So far, all the other standards worked with this approach (either because they didn’t have multiple namespaces or they included all their namespaces in the outer schema). However, this didn’t work with EML since additional namespaces were defined in the included files. This makes it a bit complicated to deal with because usually developers doesn’t care about explicitly loading the included documents and just rely on the XML Schema parsing API to do it for them. So, there are two approaches to deal this issue

1) Recursively navigate through the XML Schema DOM and get all the included schemas and gather the namespaces defined in them. Ofcourse, this has the issue of making sure that the relative paths are properly converted to absolute paths.
2) Implement a custom Input Resolver and on the fly as the XML Schema parser is fetching the included schemas, gather the namespaces.

I am yet to decide on the approach I want to take, mostly will go with the approach 2. However, to deal with EML, the included namespaces are hard-coded for EML schemas.

My recommendation for anyone creating XML Schemas is perhaps to redefine all the namespaces from the included schemas (recursively) in the outer schema. Otherwise, developers working with the schemas might face challenges depending on the sophistication of the tools they are using.

Visual Schema For Election Markup Language (EML)

Right now I am watching Senator Barack Obama speaking in Minnesota on his successful winning of the required number of delegates for the nominations. Well, that has nothing to do with this post. But yes, the fact that this year the US Presidential Elections are going to happen has prompted me to look for XML Schema specifications related to Elections and found them on the oasis-open.org website.

VisualSchema.com is pleased to offer the Visual Schemas for Election Markup Language (EML) XML Schemas.

While creating the visual schemas for EML, a few issues were encountered. They will be listed in the next post.