Until now, I've been handling extensions by defining a placeholder element that has "name" and "value" attributes as shown in the below example
<root>
<typed-content>
...
</typed-content>
<extension name="var1" value="val1"/>
<extension name="var2" value="val2"/>
....
</root>
I am now planning to switch to using xsd:any. I'd appreciate if you can help me choose th best approach
- What is the value add of xsd:any over my previous approach if I specify processContents="strict"
- Can a EAI/ESB tool/library execute XPATH expressions against the arbitrary elements I return
- I see various binding tools treating this separately while generating the binding code. Is this this the same case if I include a namespace="http://mynamespace" and provide the schema for the "http://mynamespace" during code gen time?
- Is this WS-I compliant?
- Are there any gotchas that I am missing?
Thank you
<xsd:any processContents="strict">
gives people the ability to add extensions to their XML instance documents without changing the original schema. This is the critical benefit it gives you.<xsd:any>
or not.<xsd:any>
very elegantly. This is understandable, since they have no information about what it could contain, so they'll usually give you an untyped placeholder. It's up the the application code to handle that at runtime. JAXB is particular (the RI, at least) makes a bit of a fist of it, but it's workable.<xsd:any>
makes life a bit harder on the programmer, due to the untyped nature of the bindings, but if you need to support arbitrary extension points, this is the way to do it. However, if your extensions are well-defined, and do not change, then it may not be worth the irritation factor.