Re: The application of xml:lang="" in XInclude language fixup
Hussein Shafie <[email protected]> Thu, 4 May 2023 12:04:54 +0200
| Newsgroups | gmane.editors.xxe.general |
|---|---|
| Message-ID | <[email protected]> |
On 5/4/23 02:28, Leif H Silli wrote: > The relase notes of XXE 10.4 [1] metntions this bug fix: > > «Made the language fixup of the XInclude 1.1 implementation more > conforming to the specification.» > > The new behavior is related to "language fixup" as defined by XInclude > 1.0 and 1.1 [2]. And the new behavior is that when the language fixup > algoritm concludes that the language of the embedded element is unknown, > the empty attribute xml:lang="" is applied to the included element. > > But I wonder if the implementation is too liberal in applying > xml:lang="", possibly due to unclear language of the XInclude spec. > > It seems to me as if XXE 10.4 treats <html> and <html xml:lang=""> as > equal. Let us say tha we want to embed a <div> that lives inside a > <html> element. I will show two variants of this. In the first case, the > <html> element has no xml:lang. In the second varaint, there is an > xml:lang="". > > Variant 1 : no xml:lang attribute. > > <html http://www.w3.org/1999/xhtml" > > <div id="embed-me">Hello world!</div> > </html> > > Currently, XXE 10.4 will include the div element like so, "because" it > considers the language unknown: > > <div id="embed-me" xml:lang="" >Hello world!</div> > > Variant 2 : with xml:lang="<empty>" > > <html http://www.w3.org/1999/xhtml" xml:lang="" > > <div id="embed-me">Hello world!</div> > </html> > > This is simple. XXE 10.4 will simply copy - or inherit - the xml:lang > attribute from the <html> element: > > <div id="embed-me" xml:lang="" >Hello world!</div> > > Just to be explicit: The behavior in Variant 2, is correct. But I am > honestly uncertain about Variant 1. > > XML 1.0 says this - https://www.w3.org/TR/xml/#sec-lang-tag : > > «The language specified by xml:lang applies to the element where it is > specified (including the values of its attributes), and to all elements > in its content unless overridden with another instance of xml:lang. In > particular, the empty value of xml:lang is used on an element B to > override a specification of xml:lang on an enclosing element A, without > specifying another language. Within B, it is considered that there is no > language information available, just as if xml:lang had not been > specified on B or any of its ancestors.» > > So based on XML 1.0, it does seems as if <html> and <html xml:lang=""> > are considered equal. Yes. > > There is still a practical difference, though, which is that <html> may > inherit a language from a process higher up - such as from HTTP. Correct but is this a good practice in the context of structured documents? > Whereas <html xml:lang=""> will not inherit anything from above. > > A practical benefit of the new behavior, is that it becomes possible to > discover included/embedded elements for which there is no language > specified. This can proably come in as handy. > > But there are situations where one wants the included element to inherit > the language from the parent element in the composed document (just as > one may want HTML to inherit the language from HTTP). Sorry but I don't see. > > XML 1.0 and 1.1 says that «An XInclude processor may, at user option, > suppress xml:base and/or xml:lang fixup.» [3] > > And so, because of the practical difference, it might make sense to be > able to disable langage fixup - at leaset with regard to the application > of xml:lang="" in the Variant 1 situation described above. > > [1] https://xmlmind.com/xmleditor/changes.html#v10.4.0 > [2] https://www.w3.org/TR/xinclude-11/#language > [3] https://www.w3.org/TR/xinclude-11/#creating-result > Sorry but we do not plan to implement: «An XInclude processor may, at user option, suppress xml:base and/or xml:lang fixup.» -- XMLmind XML Editor Support List [email protected] http://www.xmlmind.com/mailman/listinfo/xmleditor-support