[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-dev
Subject:    [xml-dev] Creating a "complete" specification is hard
From:       Roger L Costello <costello () mitre ! org>
Date:       2022-05-28 12:06:47
Message-ID: SA9PR09MB595215A8AAE7B38B62516DC1C8DB9 () SA9PR09MB5952 ! namprd09 ! prod ! outlook ! com
[Download RAW message or body]

Hi Folks,

Yesterday I posted a message asking:

With XML documents like this:

<Books>
    <Book>
        <Title>The Science of Programming</Title>
        <Author>David Gries</Author>
    </Book>
    <Book>
        <Title>Compiler Construction for Digital Computers</Title>
        <Author>David Gries</Author>
    </Book>
    <Book>
        <Title>The Emperor's New Mind</Title>
    </Book>
    <Book>
        <Title>Algorithms</Title>
    </Book>
    <Book>
        <Title>The Path to Power</Title>
        <Author>Robert A. Caro</Author>
    </Book>
</Books>

How can we answer this question:

              How many distinct authors are there in the book list,
              where the books with an UNKNOWN author are
              counted as 1?

It was pointed out to me that my specification is ambiguous:


  *   Should a Book element with an empty Author element and a Book element with an \
                absent Author element be treated as equivalent or as distinct?
  *   Should Book elements with no Author be counted together as a single value or \
separately as distinct values (because undefined)?

Wow!

Lesson Learned: Creating a specification that considers all cases is hard.

Let's extend the sample XML document to include a Book element with an empty Author \
element:

<Books>
    <Book>
        <Title>The Science of Programming</Title>
        <Author>David Gries</Author>
    </Book>
    <Book>
        <Title>Compiler Construction for Digital Computers</Title>
        <Author>David Gries</Author>
    </Book>
    <Book>
        <Title>The Emperor's New Mind</Title>
    </Book>
    <Book>
        <Title>Algorithms</Title>
    </Book>
    <Book>
        <Title>The Path to Power</Title>
        <Author>Robert A. Caro</Author>
    </Book>
    <Book>
        <Title>Constraint Programming Languages</Title>
        <Author></Author>
    </Book>
</Books>

Here are XPath expressions to handle each case:

Treat a Book element with an empty Author element and a Book element with an absent \
Author element as equivalent: count(distinct-values(/Books/Book/string(Author)))

Evaluating that XPath expression on the XML document yields: 3

Treat a Book element with an empty Author element and a Book element with an absent \
Author element as distinct: let $book := /Books/Book
  return
    count(distinct-values($book/Author)) + xs:integer(exists($book[not(Author)]))

Evaluating that XPath expression on the XML document yields: 4

Treat each Book element with an absent Author element as distinct:

let $book := /Books/Book
  return
    count(distinct-values($book/Author)) + count($book[not(Author)])

Evaluating that XPath expression on the XML document yields: 5

Acknowledgements

Thank you to the following people for their tremendous help and insights:


  *   Michael Kay
  *   Dimitre Novatchev
  *   Wendell Piez

/Roger


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:8.0pt;
	margin-left:0in;
	line-height:106%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
	{mso-style-priority:34;
	margin-top:0in;
	margin-right:0in;
	margin-bottom:8.0pt;
	margin-left:.5in;
	line-height:105%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:black;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:1826507387;
	mso-list-type:hybrid;
	mso-list-template-ids:584211230 1039180754 67698691 67698693 67698689 67698691 \
67698693 67698689 67698691 67698693;} @list l0:level1
	{mso-level-start-at:16;
	mso-level-number-format:bullet;
	mso-level-text:-;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Calibri",sans-serif;
	mso-fareast-font-family:Calibri;}
@list l0:level2
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level3
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l0:level4
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
@list l0:level5
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level6
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
@list l0:level7
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Symbol;}
@list l0:level8
	{mso-level-number-format:bullet;
	mso-level-text:o;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:"Courier New";}
@list l0:level9
	{mso-level-number-format:bullet;
	mso-level-text:\F0A7;
	mso-level-tab-stop:none;
	mso-level-number-position:left;
	text-indent:-.25in;
	font-family:Wingdings;}
ol
	{margin-bottom:0in;}
ul
	{margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">Hi Folks,<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Yesterday I \
posted a message asking: <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">With XML \
documents like this:<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&lt;Books&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Title&gt;The \
Science of Programming&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Author&gt;David \
Gries&lt;/Author&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Title&gt;Compiler \
Construction for Digital Computers&lt;/Title&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Author&gt;David \
Gries&lt;/Author&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Title&gt;The \
Emperor's New Mind&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&lt;Title&gt;Algorithms&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Title&gt;The Path \
to Power&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Author&gt;Robert \
A. Caro&lt;/Author&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&lt;/Books&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">How can we \
answer this question: <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; How many distinct \
authors are there in the book list, <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
where the books with an UNKNOWN author are <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
counted as 1?<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">It was pointed \
out to me that my specification is ambiguous:<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <ul style="margin-top:0in" \
type="disc"> <li class="MsoListParagraph" \
style="color:black;margin-bottom:0in;margin-left:0in;line-height:normal;mso-list:l0 \
level1 lfo1"> <span style="color:windowtext">Should a Book element with an empty \
Author element and a Book element with an absent Author element be treated as \
equivalent or as distinct?</span><o:p></o:p></li><li class="MsoListParagraph" \
style="color:black;margin-bottom:0in;margin-left:0in;line-height:normal;mso-list:l0 \
level1 lfo1"> <span style="color:windowtext">Should Book elements with no Author be \
counted together as a single value or separately as distinct values (because \
undefined)?</span><o:p></o:p></li></ul> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">Wow!<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Lesson \
Learned: Creating a specification that considers all cases is \
hard.<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Let&#8217;s \
extend the sample XML document to include a Book element with an empty Author \
element:<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&lt;Books&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Title&gt;The \
Science of Programming&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Author&gt;David \
Gries&lt;/Author&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Title&gt;Compiler \
Construction for Digital Computers&lt;/Title&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Author&gt;David \
Gries&lt;/Author&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&lt;Title&gt;The \
Emperor's New Mind&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&lt;Title&gt;Algorithms&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Title&gt;The Path \
to Power&lt;/Title&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Author&gt;Robert \
A. Caro&lt;/Author&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&lt;Title&gt;Constraint Programming Languages&lt;/Title&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&lt;Author&gt;&lt;/Author&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; &lt;/Book&gt;<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&lt;/Books&gt;<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Here are XPath \
expressions to handle each case:<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Treat a Book \
element with an empty Author element and a Book element with an absent Author element \
as equivalent:<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">count(distinct-values(/Books/Book/string(Author)))<o:p></o:p></span></p>
 <p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Evaluating \
that XPath expression on the XML document yields: 3<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Treat a Book \
element with an empty Author element and a Book element with an absent Author element \
as distinct:<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">let $book := \
/Books/Book<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">&nbsp; \
return<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp; count(distinct-values($book/Author)) + \
xs:integer(exists($book[not(Author)]))<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Evaluating \
that XPath expression on the XML document yields: 4<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Treat each \
Book element with an absent Author element as distinct:<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">let $book := \
/Books/Book <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;return <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black">&nbsp;&nbsp;&nbsp;&nbsp;count(distinct-values($book/Author)) + \
count($book[not(Author)])<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Evaluating \
that XPath expression on the XML document yields: 5<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">Acknowledgements<o:p></o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span style="color:black">Thank you to \
the following people for their tremendous help and insights:<o:p></o:p></span></p> <p \
class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <ul style="margin-top:0in" \
type="disc"> <li class="MsoListParagraph" \
style="color:black;margin-bottom:0in;margin-left:0in;line-height:normal;mso-list:l0 \
level1 lfo1"> Michael Kay<o:p></o:p></li><li class="MsoListParagraph" \
style="color:black;margin-bottom:0in;margin-left:0in;line-height:normal;mso-list:l0 \
level1 lfo1"> Dimitre Novatchev<o:p></o:p></li><li class="MsoListParagraph" \
style="color:black;margin-bottom:0in;margin-left:0in;line-height:normal;mso-list:l0 \
level1 lfo1"> Wendell Piez<o:p></o:p></li></ul>
<p class="MsoNormal" style="margin-bottom:0in;line-height:normal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal" \
style="margin-bottom:0in;line-height:normal"><span \
style="color:black">/Roger<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> </div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic