I had heard the rumor already, but by checking the XInclude errata it turns out this was right: XInclude now officially allows implementations to provide an option to disable
xml:base fixup, in other words not to produce or update
xml:base attributes in the result.
This was a long-awaited feature. Adding
xml:base attributes can cause issues such as broken schema validation (you may have to modify your schema to handle those extra
xml:base attributes, or pre-process your document before validating it) or undesired URL resolution in certain cases.
For example, with the OPS XForms engine, let's assume you want to externalize an XForms model, and include it into your XHTML page as follows:
<xhtml:head> <xi:include href="oxf:/my-app/my-xforms-model.xml"/> </xhtml:head>
The result of the inclusion, by default, looks like this:
<xhtml:head> <xforms:model xml:base="oxf:/my-app/my-xforms-model.xml"> ... <xforms:submission action="services/save" method="post"/> </xforms:model> </xhtml:head>
Now what you intended was that the relative "services/save" URL would be relative to the base URL of your XHTML page. If you loaded your page from "http://www.example.org/my-app/home", you would submit to "http://www.example.org/my-app/services/save". But because
xml:base is inserted, you actually save to "oxf:/my-app/services/save", which does not make any sense. And this is messed up just because you decided to externalize your XForms model for convenience.
So the OPS XInclude processor now includes an extension attribute,
xxi:omit-xml-base, which you can place on
xi:include elements to indicate that you don't want the inclusion to produce or update
xml:base attributes. The example above becomes:
<xhtml:head> <xi:include href="oxf:/my-app/my-xforms-model.xml" xxi:omit-xml-base="true"/> </xhtml:head>
This way, all is well and your URL resolution works as expected!
Post a Comment