I’ve posted a similar question to the one I’m about to ask here, http://marc.theaimsgroup.com/?l=xerces-c-dev&m=101845602121151&w=2, and was pointed to the DOM 3 spec as a way to solve my problem. Firstly, it would appear that the algorithms defined in appendix B have the odd issue and omission (btw, I’m not pointing fingers). For instance, asfaict, no mention is made of ascertaining the correct namespace prefix for attributes, only elements. Although this is only a minor problem it leads on to another question I have regarding the schemaInstance attribute “type” (and yes, this is yet another question on the subject of DOM serialization…)

 

Firstly, could someone tick or put a great big X against the following statements:

 

1)       All attributes by default belong to the xmlns namespace. As such you need only use createAttribute(…) in the DOM.

2)       If however, you need to create a “type” attribute of the schemaInstance namespace, you need to use createAttributeNS(…) to ensure it has the appropriate namespace.

 

Its the second statement that is causing me difficulty and especially with the xsi:type attribute. The reason being, the value of such an attribute is more often than not likely to include a namespace prefix, or at least require prefixing (e.g.xsi:type=”anotherNS:foo”). It seems to me that I have to ascertain the namespace prefix when I create this node which seems like an odd way of doing it, as was indicated in my previous question that its really only the serializer that needs to workout prefixes. But, how could a serializer ascertain the namespace for this value if statement two is correct, it would have the xsi namespace URI not anotherNS uri – it actually needs both, one for the attribute and one for the attribute value.

 

I guess I feel like I’m answering my own question, firstly I need to get the algorithms in appendix B correct. Secondly, if I happen to be creating an xsi:type attribute, then for its value I need to lookup the namespace prefix first and concatenate it with the rest of the :value before I set it. Sound right?

 

Thanks,

Scot Nielsen

 

Reply via email to