RE: Confusion on XPath Grammar concerning attribute axis

"Kay, Michael" <[email protected]> Fri, 16 Jan 2004 16:07:05 +0100
Newsgroups gmane.text.xml.xpath.general
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C3DC42.6772C65B
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

These expressions are all perfectly legal, and all return an empty
node-set (in XPath 1.0) or an empty sequence (in XPath 2.0). It's
perfectly OK to ask for all the children of an attribute node, or all
the text nodes on the attribute axis, the system will just tell you that
there aren't any.
=20
In 2.0, if you have static typing enabled, a path expression that will
always return an empty sequence can be reported as an error.
=20
Generally it's not a good idea for the grammar of a language to enforce
semantic rules. Asking for sqrt(-1) should be a semantic error rather
than a syntactic one, and the same goes for these constructs.
=20
Michael Kay
=20

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Kirmse, Daniel
Sent: 15 January 2004 16:27
To: '[email protected]'
Subject: Confusion on XPath Grammar concerning attribute axis



Hi,

I wonder what this expression means:

(1) /foo/@attr/bar

or what this one here means:

(2) /foo/@text()

ad (1):

This expression seems to be perfectly within the range of the grammar,
but I cannot understand what it means. Well /foo/@attr takes me to the
attribute "attr" of node "foo". But what does /bar do on this context?

ad(2):

Well this looks like a text() test on the attribute axis of foo. But
what is the meaning of that?



Thanks for any answers and hints!

Cheers,

Daniel






------_=_NextPart_001_01C3DC42.6772C65B
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<TITLE>Message</TITLE>

<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D097592814-16012004>These=20
expressions are all perfectly legal, and all return an empty node-set =
(in XPath=20
1.0) or an empty sequence (in XPath 2.0). It's perfectly OK to ask for =
all the=20
children of an attribute node, or all the text nodes on the attribute =
axis, the=20
system will just tell you that there aren't any.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D097592814-16012004></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D097592814-16012004>In=20
2.0, if you have static typing enabled, a path expression that will =
always=20
return an empty sequence can be reported as an =
error.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D097592814-16012004></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D097592814-16012004>Generally it's not a good idea for the =
grammar of a=20
language to enforce semantic rules. Asking for sqrt(-1) should be a =
semantic=20
error rather than a syntactic one, and the same goes for these=20
constructs.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D097592814-16012004></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D097592814-16012004>Michael Kay</SPAN></FONT></DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D097592814-16012004></SPAN></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
  <DIV></DIV>
  <DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr =
align=3Dleft><FONT=20
  face=3DTahoma size=3D2>-----Original Message-----<BR><B>From:</B>=20
  [email protected] =
[mailto:[email protected]]=20
  <B>On Behalf Of </B>Kirmse, Daniel<BR><B>Sent:</B> 15 January 2004=20
  16:27<BR><B>To:</B> '[email protected]'<BR><B>Subject:</B> =
Confusion=20
  on XPath Grammar concerning attribute axis<BR><BR></FONT></DIV>
  <P align=3Dleft><FONT face=3DArial size=3D2>Hi,</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>I wonder what this =
expression=20
  means:</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>(1)</FONT> <FONT =
face=3DArial=20
  size=3D2>/foo/@attr/bar</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>or what this one here =
means:</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>(2)</FONT> <FONT =
face=3DArial=20
  size=3D2>/foo/@text()</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>ad (1):</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>This expression seems to =
be perfectly=20
  within the range of the grammar, but I cannot understand what it =
means.</FONT>=20
  <FONT face=3DArial size=3D2>Well /foo/@attr takes me to the =
attribute</FONT> <FONT=20
  face=3DArial size=3D2>"</FONT><FONT face=3DArial =
size=3D2>attr</FONT><FONT face=3DArial=20
  size=3D2>"</FONT><FONT face=3DArial size=3D2> of node</FONT> <FONT =
face=3DArial=20
  size=3D2>"</FONT><FONT face=3DArial size=3D2>foo</FONT><FONT =
face=3DArial=20
  size=3D2>"</FONT><FONT face=3DArial size=3D2>. But what does /bar do =
on this=20
  context?</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>ad(2):</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>Well this looks like a =
text() test on=20
  the</FONT> <FONT face=3DArial size=3D2>attribute</FONT><FONT =
face=3DArial size=3D2>=20
  axis of foo. But what is the meaning of that?</FONT></P><BR><BR>
  <P align=3Dleft><FONT face=3DArial size=3D2>Thanks for any answers and =

  hints!</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>Cheers,</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>Daniel</FONT></P>
  <P align=3Dleft><A name=3D_MailAutoSig></A></P>
  <P align=3Dleft></P></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C3DC42.6772C65B--