W3C home > Mailing lists > Public > www-xml-linking-comments@w3.org > October to December 2000

Re: XPointer question - selecting locations from a location-set

From: Daniel Veillard <Daniel.Veillard@w3.org>
Date: Tue, 21 Nov 2000 16:14:09 +0100
To: Jiri Jirat <Jiri.Jirat@idoox.com>
Cc: www-xml-linking-comments@w3.org
Message-ID: <20001121161409.J2947@w3.org>
On Tue, Nov 21, 2000 at 01:55:14PM +0100, Jiri Jirat wrote:
> Hello,
>  I prepared an XPointer tutorial at
> http://www.zvon.org/xxl/xpointer/tutorial/OutputExamples/introduction.html
> a few weeks ago.

  Hi,

thanks this is an useful contribution !

> Now I have been asked the following question:
> 
> If I want to select the point (marked X) just before the string-range
> 'another',
> which expression is correct?

  Ok my answer is how I understand the string-range() definition:

> Is this correct?:
> xpointer(string-range(//*,'another')[0])

  Hum, no, that would select the first range in the returned location set

> Or should it look like this?:
> xpointer(string-range(//*,'another')[1][0])

  I think this would return an empty set,

> Or should there be some parentheses?

  IMHO the right thing is to use the 4th parameter of string-range to
limit the range to the point starting it:

xpointer(string-range(//*,'another',1,0))

> IMPORTANT: here, in this example, the location-set returned by
> "string-range(//*,'another')"
> consists just of ONE location.
> Do I have to specify also that I want the location no. one from the
> location set,
> or it is not compulsory?

  Not compulsory you are right. BTW Remember that returning multiple
ranges is perfectly legal :-)

> I could not find this in the specification.
> 
> ===============================
> Here is XML file:
> ===============================
>  <AAA>
>    <BBB bbb="111">
>      Text in the first element BBB.
>    </BBB>
>    <BBB bbb="222">
>       Text in Xanother element BBB. 
>      <DDD ddd="999">
>        Text in more nested element.
>      </DDD>
>    </BBB>
>    <CCC ccc="123" xxx="321">
>      Again some text in some element.
>    </CCC>
>  </AAA>
> ===============================

 Libxml XPointer implementation seems happy about this (at least my CVS
version)

 ~/XML ->  ./testXPath --xptr -i tst.xml "xpointer(string-range(//*,'another',1,0))"
Object is a Location Set:
 1 :   Object is a collapsed range :
   index 16 in node
       TEXT
	 content=      Text in Xanother element BBB.     ...

> May be, my question is not very clear, please, look at
> http://www.zvon.org/xxl/xpointer/tutorial/OutputExamples/xml40_out.xml.html
> and tell me your opinion.

  I think this is clear,

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | libxml Gnome XML toolkit
Tel : +33 476 615 257  | 655, avenue de l'Europe | http://xmlsoft.org/
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Rpmfind search site
 http://www.w3.org/People/all#veillard%40w3.org  | http://rpmfind.net/
Received on Tuesday, 21 November 2000 10:14:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 October 2009 08:39:41 GMT