Re: Confirmation of xml:id behaviour

On Tue, Feb 12, 2008 at 10:25:10PM +1100, Cameron McCormack wrote:
> 
> Hi Daniel.
> 
> Daniel Veillard:
> >   All I can say from an xml:id point of view is that the svg element
> > will be reported as having an attribute xml:id of type ID to the 
> > application processing the document and that the value of this
> > ID is '1' (not '0').
> 
> Sorry, yeah meant to write '1' there, not '0'.
> 
> >   Everything else you seems to assume looks dependand on how the
> > application interpret the XML, including the svg and script element,
> > and that xml:id cannot garantee it in itself.
> 
> OK, so given Document.getElementById() says:
> 
>   Returns the Element that has an ID attribute with the given value. If
>   no such element exists, this returns null.
>     — http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-getElBId
> 
> I think it should alert true.
> 
> It just seemed surprising to me that invalid IDs were effectively
> treated the same as valid ones, but if that’s what’s meant to happen,
> I’ll go with it.

  http://www.w3.org/TR/xml-id/#processing

  ------------------
  Each xml:id attribute is processed in the following way:
   ...
     - ID type assignment is performed with the normalized value.
   ...
  An xml:id processor must assure that the following constraints hold for all xml:id attributes:
     - The normalized value of the attribute is an NCName  ...

  An xml:id error occurs for any xml:id attribute that does not satisfy the constraints.
  ------------------

Hence to me the ID type assigment is done and reported to the application (that
is beginning of section 5), and an error MUST be reported to the application.
So the application get both informations. I would expect the IDness to stick
and getElementById() to work. How and if the application will report the error
sounds very dependant of the kind of application (an editor definitely should).

For the anecdote, for a long long time I tried in libxml2 to no pass non-NCNames
as ID to the applications, and got persistent continuous reports that 
applications expected to see the malformed IDs anyway (this has been buried in 
existing processes :-( ) and in the end I changed. You get the error as a 
validity kind of warning in libxml2 since this correspond to a validity
checking for XML-1.0.

Daniel


-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

Received on Tuesday, 12 February 2008 12:27:08 UTC