XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

Margaret Gruen-Kerr
XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

The test externalcontextitem-1.xq performs a nodename selection with no context item. The reference result is the error XPDY0002.

I couldn't find a clear answer in the spec why  a node selection on an empty sequence (which implies no context item) return the empty seq. and the node selection with no context item returns an error.

It's clear why functions that try to access the context item, report an error when there is no context item, however not when a nodename selection is performed.

Regards Margaret
... Margaret A. Grün-Kerr
... Quality Assurance Engineer
... Altova GmbH

===================================================================
Altova®  accelerates  application development  and  data management
projects with  software  and  solutions  that enhance  productivity
and maximize results. Uncover why Altova is the preferred choice of
over 2 million developers worldwide! Look into
www.altova.com today
XML Suite:  XMLSpy  MapForce StyleVision  SemanticWorks SchemaAgent
Developer Tools: UModel DiffDog  FREE: Authentic,  AltovaXML engine
NEW in v2006:  Advanced standards compliance,  XSLT 2.0, XPath 2.0,
XQuery 1.0,  Legacy text file parsing, Web Services implementation,
Semantic Web,  RDF / OWL editor,  VS.Net 2005 & Eclipse 3.1 support
UML 2.1 support,  UML Sequence Diagrams, C# code-gen and round-trip
===================================================================

Altova,  XMLSpy, MapForce, StyleVision, SemanticWorks, SchemaAgent,
UModel,  DiffDog,  ACXE,  AltovaXML,  and Authentic  are trademarks
and/or registered trademarks of Altova GmbH in the United States of
America, the European Union, and numerous other countries.
The information transmitted in this message and/or as an attachment
to it  is intended  only for the  person or  entity to  which it is
addressed and may contain confidential  and/or privileged material.
Any  review,  retransmission,  dissemination  or  other use of,  or
taking of any action in reliance upon,  this information by persons
or entities other than the intended recipient is prohibited. If you
received this in error,  please contact  the sender  and delete the
material from any computer.  Altova GmbH  and  Altova, Inc.  do not
accept legal responsibility  for the contents of this message.  Any
views or opinions  presented are solely  those of the author and do
not  necessarily  represent those of  Altova GmbH and  Altova, Inc.
unless otherwise specifically stated. Thank you!


Reply | Threaded
Open this post in threaded view
|

Re: XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

Frans Englich-2

On Tuesday 22 August 2006 09:25, Margaret Gruen-Kerr wrote:

Hello Margaret,

> The test externalcontextitem-1.xq performs a nodename selection with no
> context item. The reference result is the error XPDY0002. I couldn't find a
> clear answer in the spec why  a node selection on an empty sequence (which
> implies no context item) return the empty seq. and the node selection with
> no context item returns an error. It's clear why functions that try to
> access the context item, report an error when there is no context item,
> however not when a nodename selection is performed.

Inside user functions the focus is undefined. See 3.1.5 Function Calls step 4:

<quote>
During evaluation of a function body, the focus (context item, context
position, and context size) is undefined, except where it is defined by some
expression inside the function body.
</quote>

I hope I am correct and that it helps.


Cheers,

                Frans

Reply | Threaded
Open this post in threaded view
|

RE: XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

Margaret Gruen-Kerr
In reply to this post by Margaret Gruen-Kerr
RE: XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

Frans -
You are right, but I am afraid it does not answer my question, I will try to rephrase it:
Should a node name test on an undefined context return differently than a nodename test on a empty sequence?
The correct result for  a nodename selection on a function returning the empty sequence is the empty sequence (the context size is not greater than zero)

 noResult()/nodeName==>empty sequence

From reading the spec. is it not acceptable for  a nodename selection on an undefined context to return the empty sequence also?


... Margaret A. Grün-Kerr
... Quality Assurance Engineer
... Altova GmbH

===================================================================
Altova®  accelerates  application development  and  data management
projects with  software  and  solutions  that enhance  productivity
and maximize results. Uncover why Altova is the preferred choice of
over 2 million developers worldwide! Look into www.altova.com today
XML Suite:  XMLSpy  MapForce StyleVision  SemanticWorks SchemaAgent
Developer Tools: UModel DiffDog  FREE: Authentic,  AltovaXML engine
NEW in v2006:  Advanced standards compliance,  XSLT 2.0, XPath 2.0,
XQuery 1.0,  Legacy text file parsing, Web Services implementation,
Semantic Web,  RDF / OWL editor,  VS.Net 2005 & Eclipse 3.1 support
UML 2.1 support,  UML Sequence Diagrams, C# code-gen and round-trip
===================================================================

Altova,  XMLSpy, MapForce, StyleVision, SemanticWorks, SchemaAgent,
UModel,  DiffDog,  ACXE,  AltovaXML,  and Authentic  are trademarks
and/or registered trademarks of Altova GmbH in the United States of
America, the European Union, and numerous other countries.
The information transmitted in this message and/or as an attachment
to it  is intended  only for the  person or  entity to  which it is
addressed and may contain confidential  and/or privileged material.
Any  review,  retransmission,  dissemination  or  other use of,  or
taking of any action in reliance upon,  this information by persons
or entities other than the intended recipient is prohibited. If you
received this in error,  please contact  the sender  and delete the
material from any computer.  Altova GmbH  and  Altova, Inc.  do not
accept legal responsibility  for the contents of this message.  Any
views or opinions  presented are solely  those of the author and do
not  necessarily  represent those of  Altova GmbH and  Altova, Inc.
unless otherwise specifically stated. Thank you!


-----Original Message-----
From: Frans Englich [[hidden email]]
Sent: August 22, 2006 13:01
To: Margaret Grün-Kerr (QA)
Cc: [hidden email]
Subject: Re: XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

On Tuesday 22 August 2006 09:25, Margaret Gruen-Kerr wrote:

Hello Margaret,

> The test externalcontextitem-1.xq performs a nodename selection with no
> context item. The reference result is the error XPDY0002. I couldn't find a
> clear answer in the spec why  a node selection on an empty sequence (which
> implies no context item) return the empty seq. and the node selection with
> no context item returns an error. It's clear why functions that try to
> access the context item, report an error when there is no context item,
> however not when a nodename selection is performed.

Inside user functions the focus is undefined. See 3.1.5 Function Calls step 4:

<quote>
During evaluation of a function body, the focus (context item, context
position, and context size) is undefined, except where it is defined by some
expression inside the function body.
</quote>

I hope I am correct and that it helps.


Cheers,

                Frans

Reply | Threaded
Open this post in threaded view
|

Re: XQTS - Test externalcontextitem-1.xq, nodename selection on an undefined context same as on empty sequence

Frans Englich-2

On Tuesday 22 August 2006 12:17, Margaret Gruen-Kerr wrote:
> Frans -
> You are right, but I am afraid it does not answer my question, I will try
> to rephrase it: Should a node name test on an undefined context return
> differently than a nodename test on a empty sequence?

Yes, the former is a type error(e.g, it doesn't return at all) while the
latter do return.

However, note that it is significant what the empty sequence originates from
in "a nodename test on a empty sequence". Evaluating b in a/b is ok if `a'
evaluates to the empty sequence(subsequently, b will as well evaluate to the
empty sequence). When evaluating only `b'(therefore implicitly accessing the
focus), the focus is either undefined(which it is inside a user function, for
example), or be defined. However, the focus cannot never be the empty
sequence.

See 2.1.2 Dynamic Context:

[Definition: The context item is the item currently being processed. An item
is either an atomic value or a node.] // NB, this is cardinality exactly-one

[Definition: The context position is the position of the context item within
the sequence of items currently being processed.] It changes whenever the
context item changes. When the focus is defined, the value of the context
position is an integer greater than zero.
[Definition: The context size is the number of items in the sequence of items
currently being processed.] Its value is always an integer greater than zero.

> The correct result
> for  a nodename selection on a function returning the empty sequence is the
> empty sequence (the context size is not greater than zero)
> noResult()/nodeName==>empty sequence

Yes, assuming the function manages to evaluate to the empty sequence without
errors. It is ok for a axis step to evaluate to the empty sequence.

> From reading the spec. is it not acceptable for  a nodename selection on an
> undefined context to return the empty sequence also?

No, if any expression such as a node test accesses the focus and it is
undefined, XPDY0002 must be raised.

Perhaps the key to this is that the focus never can be the empty sequence.


Cheers,

                Frans

>
>
> ... Margaret A. Grün-Kerr
> ... Quality Assurance Engineer
> ... Altova GmbH
>
> ===================================================================
> Altova®  accelerates  application development  and  data management
> projects with  software  and  solutions  that enhance  productivity
> and maximize results. Uncover why Altova is the preferred choice of
> over 2 million developers worldwide! Look into www.altova.com today
> XML Suite:  XMLSpy  MapForce StyleVision  SemanticWorks SchemaAgent
> Developer Tools: UModel DiffDog  FREE: Authentic,  AltovaXML engine
> NEW in v2006:  Advanced standards compliance,  XSLT 2.0, XPath 2.0,
> XQuery 1.0,  Legacy text file parsing, Web Services implementation,
> Semantic Web,  RDF / OWL editor,  VS.Net 2005 & Eclipse 3.1 support
> UML 2.1 support,  UML Sequence Diagrams, C# code-gen and round-trip
> ===================================================================
>
> Altova,  XMLSpy, MapForce, StyleVision, SemanticWorks, SchemaAgent,
> UModel,  DiffDog,  ACXE,  AltovaXML,  and Authentic  are trademarks
> and/or registered trademarks of Altova GmbH in the United States of
> America, the European Union, and numerous other countries.
> The information transmitted in this message and/or as an attachment
> to it  is intended  only for the  person or  entity to  which it is
> addressed and may contain confidential  and/or privileged material.
> Any  review,  retransmission,  dissemination  or  other use of,  or
> taking of any action in reliance upon,  this information by persons
> or entities other than the intended recipient is prohibited. If you
> received this in error,  please contact  the sender  and delete the
> material from any computer.  Altova GmbH  and  Altova, Inc.  do not
> accept legal responsibility  for the contents of this message.  Any
> views or opinions  presented are solely  those of the author and do
> not  necessarily  represent those of  Altova GmbH and  Altova, Inc.
> unless otherwise specifically stated. Thank you!
>
>
> -----Original Message-----
> From: Frans Englich [mailto:[hidden email]]
> Sent: August 22, 2006 13:01
> To: Margaret Grün-Kerr (QA)
> Cc: [hidden email]
> Subject: Re: XQTS - Test externalcontextitem-1.xq, nodename selection on an
> undefined context same as on empty sequence
>
> On Tuesday 22 August 2006 09:25, Margaret Gruen-Kerr wrote:
>
> Hello Margaret,
>
> > The test externalcontextitem-1.xq performs a nodename selection with no
> > context item. The reference result is the error XPDY0002. I couldn't find
> > a clear answer in the spec why  a node selection on an empty sequence
> > (which implies no context item) return the empty seq. and the node
> > selection with no context item returns an error. It's clear why functions
> > that try to access the context item, report an error when there is no
> > context item, however not when a nodename selection is performed.
>
> Inside user functions the focus is undefined. See 3.1.5 Function Calls step
> 4:
>
> <quote>
> During evaluation of a function body, the focus (context item, context
> position, and context size) is undefined, except where it is defined by
> some expression inside the function body.
> </quote>
>
> I hope I am correct and that it helps.
>
>
> Cheers,
>
> Frans