Re: === Identifying a unique node in a DOM tree ===

Subject: Re: === Identifying a unique node in a DOM tree ===
From: "Khalid Asad" <asad@xxxxxxxxxxxxx>
Date: Wed, 31 May 2000 10:34:07 -0400
Unique IDs are sometimes a problem, because there is the issue of how to get
them into a document that does not already have 'em. And then there's the
issue of inserting them into a doc that has a DTD with no place for 'em.

Khalid

----- Original Message -----
From: "Dan Morrison" <dman@xxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxx>
Sent: Sunday, May 28, 2000 7:57 PM
Subject: Re: === Identifying a unique node in a DOM tree ===


> I (.dan.) posted a while back...
>
> > > Although you probably understand what I mean if I was to
> > > indicate a path
> > > like "http://my.xml.com/document.xml#/root/chapter/section";,
> > > the fact is
> > > that that notation CANNOT work.
> >
> Kevin Williams wrote:
> >
> > Only in the sense that a (hypothetical) construct like
> >
> > c:/documents/root*/chapter*/section*
> >
> > doesn't work.
>
> That was my point exactly, it's those _implicit_ wildcards that I would
> label a 'gotcha'.
>
> > One of the
> > nice things about XPointer (IMO) is that you can use it to point to more
> > than one node
>
> V. true! It is totally powerful for doing this job. It just 'thinks
> different' if you're used to unique paths...
> Coming from SQL, where every 'Select' returns an array, it's less of a
> brain-strain.
>
> And as for the question raised in this thread, the correct answer was
> posted by
>
> Khalid Asad
> > If you have an xapth = '/doc/name[4]/@first'  you will get the 'first'
> > attribute node of the 4th 'name' element. You can refer to this node to
> > update the original document.
>
> Which mimics the solution indicated in my original post:
> > something like document.xml#/root[0]/chapter[1]/section[1]
>
> So quite clearly it can be done!
>
> From Johnathan's question
> > is there an XML or DOM implementaion
> > that uniquely identifies a node?
>
> ... well sure. My observation was just a caveat to do specifically with
> XSLT, and most extant programatical implimentations have even more
> control than my pseudo XPATH example. (ooOOoo big words...)
>
> The later question :
> > I want to be able to ask the node.."Who are you" and it would reply "I
am
> > currently /.people.person.name.John"
>
> Relys on an external index. What do you mean by 'currently'? Is that a
> variable, or something to do with the order of processing?
> If your structure was
>
> <people>
>   <person userid="55"><name>John</name><title>Mr</title></person>
>   <person userid="66"><name>Jack</name><title>Sir</title></person>
> </people>
>
> ...It's trivial to use
> <xsl:template match="person"><xsl:value-of select="name"
> /></xsl:template>
>
> OTOH, you can also construct a query for
>
> <xsl:value-of select="/people/person/[@userid='55']/name" />
>
> (there may be something wrong with that syntax)
> ... if you know which one you're trying to ID. Otherwise you use the
> ordinal index.
>
> ... So Unique IDs are the other way to go. And very handy they are too.
> That's why Cocoon1 presented me with such F***ed-up paths when it was
> trying to id an XML node as an URL. Eventually I understood its
> 'wisdom'.
>
> .dan.
>
>
> :=====================:====================:
> : Dan Morrison        : The Web Limited    :
> :  http://here.is/dan :  http://web.co.nz  :
> :  dman@xxxxxxxx      :  danm@xxxxxxxxx    :
> :  04 384 1472        :  04 495 8250       :
> :  025 207 1140       :                    :
> :.....................:....................:
> : If ignorance is bliss, why aren't more people happy?
> :.........................................:
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread