[whatwg] id and xml:id

Henri Sivonen wrote:
> On Apr 2, 2006, at 18:56, fantasai wrote:
> 
>> I'd rather see the id attribute restricted to an NCName token insofar
>> as possible. We can make an exception for Hixie's repetition  templates,
>> but otherwise I think it should be compatible with the XML ID syntax.
> 
> Do you mean common attrs should have a co-occurrence constraint that  
> changes the datatype of the id attribute if the repeat attribute is  
> present?

Yes. Or, at the very least, if the repetition module is loaded.

> I was planning on defining the datatype of the id attribute as
>   xsd:string {
>     pattern = "\S+"
>   }
> 
> NCName with the exception that it allows [ and ] will be one huge  
> regexp. (But doable, of course.) If that is what we want, the syntax  
> should probably be
> (Letter | '_') (NCNameCharWithout02D1and00B7)* (('[' | #x02D1)  ( 
> NCNameCharWithout02D1and00B7)+ (']' | #x00B7)))?  ( 
> NCNameCharWithout02D1and00B7)*
> with the XML 1.0 definitions of Letter and NCNameChar.

Cool, that would even catch mismatched brackets. :)

>> The concept of "idness" is a useful one for many tools, and even if
>> browsers don't care what characters there are, other tools do. We  can't
>> express IDness in a schema if we insist on ignoring its syntactic
>> restrictions.
> 
> I didn't bother to make that argument, because I thought changing the  
> language to fit schemas wouldn't go down well with Hixie. :-)
> 
> (In http://hsivonen.iki.fi/lists-in-attributes/ I tried to bring a  
> general "less code and more reuse of correct code" argument into it  
> instead of only playing the "it's incompatible with my schema  language 
> of choice" argument.)

It's not "my schema language of choice", it's "the top three (by a long
shot) schema languages in use for XML".

> I wasn't even expecting to be able to do IDREF integrity checks in  
> RELAX NG. I was planning on doing it in Schematron or Java. Besides,  
> general IDREF integrity checking does not check that, for example,  the 
> form attribute references only form elements and not just any ids.

I would want that in the RelaxNG schema because there are editing tools
that hook into RelaxNG, but not many (or any besides validators) that can
hook into Schematron (Glazou, for example, is working on a RelaxNG-driven
editor.) RelaxNG /can/ do IDREF integrity checks. The part about form
attributes referencing only form elements can be checked by Schematron.
 From an authoring standpoint, the *most* useful part of IDREF integrity
checking is to check against typos, not against misinterpretation of the
idref attribute's intent. :)

~fantasai

Received on Sunday, 2 April 2006 14:00:23 UTC