- From: Alex Milowski <alex@milowski.org>
- Date: Thu, 6 Sep 2007 09:38:15 -0700
- To: "XProc WG" <public-xml-processing-model-wg@w3.org>
This proposal gets us a long way there. It does not cover the case where a generated prefix conflicts with a existing prefix on descendants of the element where the namespace declaration was added. I'm willing to let the serializer deal with that situation but encourage implementations to detect (or avoid) and fix such problems. That is, I could generate prefixes that are UUIDs and, while *huge*, they would never conflict. A implementation could then have a "formula 1 mode" that could crash and burn or a "super safe" mode that uses something like a UUID. As such, there are solutions to this problem that guarantee generated prefixes do not conflict with existing prefixes. Here's the proposal: In general: "Unless stated otherwise, when a namespace binding is added, a unique prefix is generated." "Any element or attribute generated by a step in this library as output must have a namespace name binding in the in-scope namespaces of that generated element." 1. p:add-attribute: If a namespace binding does not exist for the namespace name of the attribute, a namespace binding must be added where the prefix from the QName should be used if it is not already bound to another namespace. Otherwise, the prefix bound to the attribute's namespace in the in-scope namespaces is used in the attribute information item generated. 2. p:insert and p:replace When the element is copied into the resulting document, all the in-scope namespaces must be declared unless the prefix is bound to the same namespace name by an ancestor. 3. p:rename If the target being renamed is an element, the following namespace adjustments must be made for the namespace name used by the new element: * if the namespace name is not bound to a prefix, a namespace declaration must be added where the prefix from the QName should be used if it is not already bound to another namespace. . Otherwise, the prefix bound to the namespace name must be used. * if there is no namespace name, a default namespace name declaration must be added or replaced setting it to the empty string (no namespace). * if the default namespace name is changed and there is an in-scope default namespace name, the original default namespace name must be declared on all child elements. If the target being renamed is an attribute, then if the namespace name is not bound to a prefix, a namespace declaration must be added where the prefix from the QName should be used if it is not already bound to another namespace. . Otherwise, the prefix bound to the namespace name must be used. 4. p:wrap If the namespace name is not bound to a prefix, a namespace declaration must be added where the prefix from the QName should be used if it is not already bound to another namespace. . Otherwise, the prefix bound to the namespace name must be used. 5. p:wrap-sequence The namespace name must be declared using the prefix specified. Note: There are no consequences here since we are wrapping document elements and there are no in-scope namespaces except the predefined namespaces and prefixes. 6. p:unwrap Any namespace declarations on the element being unwrapped must be copied to the element children. 7. p:set-attributes For each attribute being added, if a namespace binding does not exist for the namespace name of the attribute, a namespace binding must be added where the prefix from the QName should be used if it is not already bound to another namespace. Otherwise, the prefix bound to the attribute's namespace in the in-scope namespaces is used in the attribute information item generated. 8. p:xslt When an element is generated from the xsl:element or an attribute from xsl:attribute, this step must guarantee that an namespace declaration exists for the namespace name used. As necessary, the step must add namespace declarations in the output of the transformation if the XSLT processor does not do so. -- --Alex Milowski "The excellence of grammar as a guide is proportional to the paucity of the inflexions, i.e. to the degree of analysis effected by the language considered." Bertrand Russell in a footnote of Principles of Mathematics
Received on Thursday, 6 September 2007 16:38:20 UTC