Well, it looks like the actual implementation is closer to what I just described than I was actually aware of. In my test, a binding correctly used the namespaces defined further up in the document. I tried declaring the namespace at xforms:model and office:document and both could be used correctly in a binding as expected...

<office:docuemnt xmlns:my="urn:myurn">
...
<xforms:model>
  <xforms:instance>
    <root>
      <my:test>hello</my:test>
    </root>
  <xforms:instance>
<xforms:bind name="binding1" nodeset="/root/my:test"/>
</xforms:model>

The same also worked with attributes as in
...
<my:test my:attr="test">hello</my:test>
...
<xforms:bind name="binding1" nodeset="/root/my:test/@my:attr"/>
...

This suggests, that I haven't actually understood your scenario correctly. Can you see where what you are trying to do isn't covered by what I described here?

Bests,
Lars

Lars Oppermann wrote:
I had a look at the code that creates the instance DOM during import (when the .odt file is read) and did some tests to see what happens to the namespaces.

What I found is, that contrary to my earlier assumptions, namespaces are indeed propagated to the xforms instances and become part of the DOM that is build for the data instances.

The remaining problem is, that the bindings only register namespaces that are declared directly on the xforms:bind element with the xpath evaluation context. Changing the code so that the xpath evaluation context also honors any namespace declarations at the instance's root element is easy. However, it is not be a solution to all the problems because the namespace declaration in the DOM happens at the point where the namespace is first used.

Here is what happens, say we start with a document like this:
<office:document xmlns:myns="urn:something" xmlns:office...>
...
<xforms:model>
<xforms:instance>
  <root>
    <myns:element>Hello World</mynselement>
  </root>
<xforms:instance>
<xforms:bind nodeset="/myns:element"/>
...

In the current implementation, the myns namespace will be correctly passed to the DOM created for the xforms:instance's content. However, the binding will not work. The binding will only work if it is declared as follows:
<xforms:bind nodeset="/myns:element" xmlns:myns="urn:something"/>

The change that I described above, where namespace declarations at the instance DOM root can be registered for XPath evaluation doesn't help either. Because of the DOM handles namespace declarations (createElementNS())

The instance will actually look like this:

<root>
  <myns:element xmlns:myns="urn:something">Hello World</mynselement>
</root>

Hence, the namespace is not known at the root of the document because it is not used there.

Furthermore, it is not possible to register all the namespaces up to the node referenced in the binding, because in order to evaluate the binding, you need to know about those namespaces first.

Thus, the real fix seems to be, that namespaces that are declared up to the xforms:model element must be made available to the bindings. And also be exported in some useful way again when the document is saved.

From what I could see so far (and this is now mostly a note to myself) that the strategy to implement this would be as such: - On import, when the XFormsModel is constructed, add to it a map of all the namespaces declared so far say NamespacesFromDocument. - Whenever a binding needs to be evaluated, register the namespaces mappings from this map at the evaluation context. On export, when the namespaces are written to the document root element, ask the XFormsModel for all namespaces it knows, so that they are written out.

This would not maintain the exact location of namespace declarations but that is not of relevance.





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to