<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16414" name=GENERATOR><!--[if !mso]>
<STYLE>v\:* {
        BEHAVIOR: url(#default#VML)
}
o\:* {
        BEHAVIOR: url(#default#VML)
}
w\:* {
        BEHAVIOR: url(#default#VML)
}
.shape {
        BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]-->
<STYLE>@font-face {
        font-family: Tahoma;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: Arial; mso-style-type: personal
}
SPAN.EmailStyle18 {
        COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
        page: Section1
}
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Given the source
XML:<o:p></o:p></SPAN></FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=Section1>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><sample x=”banana cherry” />
and *<B><SPAN style="FONT-WEIGHT: bold">no</SPAN></B>* schema to validate
against, the result of the expression “if (@x = ('apple', 'pear', 'orange'))
then <e/> else <f/>” is atomized into an untyped atomic sequence
that consists of one value, “banana cherry”. <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">If, however, there is a schema to
validate against, and it defines the type of “x” as NMTOKENS, then the result
is a sequence of two atomic NMTOKEN values, “banana” and
“cherry”.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Do I
understand this correctly?<FONT color=#0000ff><SPAN
class=665311423-07052007> </SPAN></FONT></SPAN></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT
color=#0000ff><SPAN class=665311423-07052007></SPAN></FONT></SPAN> </P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><FONT
color=#0000ff><SPAN class=665311423-07052007>Yes. Well not quite: it's
the typed value of the attribute x you are talking about, not the result of
the "if" expression.</SPAN></FONT></SPAN></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">I do see from the example how nodes and (atomic)
values interact, but it seems to confirm my prior understanding of node trees
since, in the example given, the result of the @x expression is (first) a node
whose value is (then) atomized. So I’m still thinking initially of the node
tree and then about how a given node value is or is not atomized. What I’m not
tracking with is thinking of atomic values without, or apart from,
nodes. <FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=665311423-07052007> </SPAN></FONT></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=665311423-07052007></SPAN></FONT></FONT></FONT></SPAN></FONT> </P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN class=665311423-07052007>Well, the the sequence-of-strings
('apple', 'pear', 'orange') has never been anywhere near a node. And you can
write a query such as avg(1 to 10) that doesn't involve any nodes in either
the input or output, but which does involve a sequence of
integers. </SPAN><o:p></o:p></FONT></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">In your second example, do you refer to this as a
heterogeneous sequence because in one case evaluating the expression results
in an atomic value (perhaps “final”), while in another it results in nothing
(if there is no “status” attribute)?<FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=665311423-07052007> </SPAN></FONT></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=665311423-07052007></SPAN></FONT></FONT></FONT></SPAN></FONT> </P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN class=665311423-07052007>No, it's heterogeneous because (@x,
'n/a) is a sequence of two items, one of which is a node and the other is
an atomic value.</SPAN></FONT></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=665311423-07052007></SPAN></FONT></FONT></FONT></SPAN></FONT> </P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=665311423-07052007>Michael Kay</SPAN></FONT></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN class=665311423-07052007><A
href="http://www.saxonica.com/">http://www.saxonica.com/</A></SPAN></FONT></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=665311423-07052007></SPAN></FONT></FONT></FONT></SPAN></FONT> </P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN
class=665311423-07052007> </SPAN><o:p></o:p></FONT></FONT></FONT></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal><B><FONT face=Tahoma size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT
face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"> Michael
Kay [mailto:mike@saxonica.com] <BR><B><SPAN
style="FONT-WEIGHT: bold">Sent:</SPAN></B> Monday, May 07, 2007 4:11
PM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> Smith, Donald T.;
talk@x-query.com<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> RE:
[xquery-talk] items as nodes or atomic
values</SPAN></FONT><o:p></o:p></P></DIV>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">When you write the
expression</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">if (@x = ('apple',
'pear', 'orange')) then <e/> else
<f/></SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">this is what
happens.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">1. The expression @x
is evaluated. The result of this expression is a sequence containing a single
attribute node.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">2. The result of (1)
is atomized. If there is no schema, the result is a sequence containing a
single atomic value of type xs:untypedAtomic. If there is a schema, however,
that describes the type of @x as xs:NMTOKENS and the actual value of @x is
"banana cherry", then the result of atomization is a sequence of two (atomic)
xs:NMTOKEN values.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">3. The result of (2)
is compared with the sequence-of-strings ('apple', 'pear',
'orange')</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">4. The result of the
comparison in (3) is a sequence containing a single xs:boolean
value</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">I hope this shows how
values consisting of nodes and values consisting of atomic values interact,
and how atomic values can exist independently of nodes. In fact, XPath 1.0
allowed either sets of nodes, or singleton atomic values. XPath 2.0 has
generalized this to also allow sets/sequences of atomic values, and singleton
nodes.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">In this example there
are no heterogeneous sequences, but they can arise and they can be very
useful. Here's a handy example:</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"><e
status="{(@status, 'n/a')[1]}"/></SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">which sets the value
of the status attribute on the new element to a copy of the status attribute
of the context node if it exists, or to the string 'n/a' otherwise. This
involves a filter expression in which the sequence being filtered contains an
attribute node and a string.</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Hope this
helps!</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Michael
Kay</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"><A
href="http://www.saxonica.com/">http://www.saxonica.com/</A></SPAN></FONT><o:p></o:p></P>
<BLOCKQUOTE
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 4pt; PADDING-BOTTOM: 0in; MARGIN: 5pt 0in 5pt 3.75pt; BORDER-LEFT: blue 1.5pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: medium none">
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><B><FONT face=Tahoma
size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT
face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">
talk-bounces@x-query.com [mailto:talk-bounces@x-query.com] <B><SPAN
style="FONT-WEIGHT: bold">On Behalf Of </SPAN></B>Smith, Donald
T.<BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> 07 May 2007
21:29<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B>
talk@x-query.com<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B>
[xquery-talk] items as nodes or atomic values</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">This may be a well-worn
question. If so, please point me to the location of the discussion.
Otherwise. . .<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I’m thinking through the
XQuery/XPath data model. The last paragraph in section 3.0 has me puzzling:
“</SPAN></FONT><SPAN lang=EN>The data model also supports values that are
not nodes. Examples of these are sequences of <A title="atomic value"
href="http://www.w3.org/TR/2007/REC-xpath-datamodel-20070123/#dt-atomic-value#dt-atomic-value">atomic
values</A>, or sequences mixing nodes and atomic values. These are necessary
to be able to represent the results of intermediate expressions in the data
model during expression processing.</SPAN><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">”<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I’m accustomed, from XPath 1.0,
to thinking of trees of nodes, so I’m not quite getting what it means
to have items in sequences that are either nodes or atomic values. Since an
atomic value is a string that conforms to an atomic type, atomic types are
schema-defined, and nodes may or may not have schema-defined datatypes, I
don’t understand the case where an atomic type would not be associated with
– and so represented by -- a node. In other words, I can’t image a
XQuery/XPath sequence as anything other than a node tree, which clearly
shows I’m still in XPath 1.0 land.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The last line I quoted above
indicates that this whole issue arises from something that goes on during
expression processing, so perhaps this is an issue that only matters to
those who write XQuery/XPath engines. At any rate, if anyone can clarify
this issue for me, I’d appreciate it.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Don
Smith</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Information
Architect<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">American
Airlines<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">817-967-0310</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P></BLOCKQUOTE></DIV></BLOCKQUOTE></BODY></HTML>