Next in thread →
Next in month →
Re: [?old?] determining ID-ness in XML
From: "Jimmy Cerra" <> > > I'm sorry if I'm bringing up a problem that is already fixed. (I haven't found > any info the contrary, though.) In one of your posts on how to specify IDs in > DTD-less XML document (1), I recognize a potential problem. > > > --- > > The PI alternative has no such problems: > > <root> > > <?xml-typeinfo idnames="id"?> > > <foo id="a"/> > > <foo id="b"/> > > <foo id="c"/> > > <!-- following have a id attr that should not be treated as ID --> > > <?xml-typeinfo idnames=""?> > > <bar id="a"/> > > <bar id="c"/> > > <bar id="d"/> > > <root/> > > Conceptually, we could say that PIs do have scope. A reasonable definition > > would be that they cover everything from the point of declaration to the end > > of the containing element... > > Declaring idname="" in the processing instruction to 'un-ID' the id attribute > seems too restrictive in my view. What if there were two id variables, and I > wanted on to "stop" being an id but the other to continue? The idname PI could > be re-declared to have only on of the attribute names specified, as in: > > ] <root> > ] <?xml-typeinfo idnames="id name"?> > ] <foo id="a"/> > ] <foo id="b"/> > ] <foo name="c"/> > ] <!-- following have a id attr that should not be treated as ID --> > ] <?xml-typeinfo idnames="name"?> > ] <bar id="a"/> > ] <bar id="c"/> > ] <bar name="d"/> > ] </root> > > However, that would mean that every element declared to be an id would stop > being one UNLESS I specified it still be one. I think that the idname should be > explicitly 'un-declared' with a tilde, '~' (which means 'not' to some > mathematicians): > > ] <root> > ] <?xml-typeinfo idnames="id name"?> > ] <foo id="a"/> > ] <foo id="b"/> > ] <foo name="c"/> > ] <!-- following have a id attr that should not be treated as ID --> > ] <?xml-typeinfo idnames="~id"?> > ] <bar id="a"/> > ] <bar id="c"/> > ] <bar name="d"/> > ] </root> > > That method allows some additional flexibility to add or delete attributes from > being an id; well, I think it does relative to this solution. Good idea. One remaining problem, though, would be if "id" had been declared as an ID higher up in the document without the author's knowledge. I'm not sure how we'd get around this problem except by counting each ID declaration and using ~id to reduce the id attribute's "reference count". I think perhaps that's getting getting a bit too coimplicated. > > --- > > This would be a similar kind of scope to variables in C++. PIs occurring > > before the root element would have "file scope", PIs occurring in element > > content would be 'visible' from the point of declaration until the end of that > > element, including child elements occurring after the PI, but not those > > occurring before it. > > I don't like this, since this means that different parts of a document can have > different style-sheets attached (PIs specify them too). An unscrupulous author > could apply XSLTs to parts of the document, while the poor XSLT processor will > get confused as those parts cannot be valid XML by themselves. I don't think that's a problem. The PI for declaring an XSLT stylesheet only has meaning when it occurs within the document prolog - see http://www.w3.org/TR/xml-stylesheet/ Regards ~Rob -- Rob Lugt ElCel Technology http://www.elcel.com
Next in thread →
Next in month →