Given an XML document without any namespace information, and its schema, what is the easiest way to add the namespace information in? This is a very general problem, and I think there should be some general solutions out there. Can someone provide pointers on this? Here is a simplified example:
Raw XML: It is known that the root element PurchaseOrder is of type PurchaseOrderType in namespace "urn:po.api".
These are the sample Schemas:
Based on the above information, the namespace information needs to be added into the Raw XML as follows:
Does anyone have pointers to how this can be done while taking into account all the contructs that XML schema supports?
The software that is creating the XML-based document should create it with the namespace data.
Joined: Mar 12, 2011
Thanks for yor reply. However that is not an option. The raw XML documents are already without namespace information. The schemas adhere to a restriction such that the raw XML documents will never have two elements with the same local name but in different namespaces as siblings in any part of the XML document. This means that even though there is no namespace information, yet there is no ambiguity for any element.
The first question is this a solvable problem or not?
If not, why not? And if it is solvable, what is the best approach?
Joined: Apr 16, 2008
Applying namespace data to the known XML instance can be done by an individual with significant XML programming skills. Business requirements for every element and attribute in the instance will be required.
...while taking into account all the contructs that XML schema supports.
Whether this is possible or not depends on the size, complexity, and granularity of the XML language which is defined in the schema AND the programming style of the XML schema itself. If possible, this would require someone with expert-level XML programming skills.
Good luck and welcome to the JavaRanch - A friendly place for programming greehorns!