RE: XForms CR - 7.10.1 Another XPath 1.0 Conformance Question

<<
7.10.1 in the CR is not totally clear (at least to me). Do you think it is
possible to use the instance() function to reference the *original* value of
a piece of data contained in an <xforms:instance> element? If so, which
XPath expression could a document author use to achieve that?
>>
 
If the instance was specified inline than the author would have to load the
actual source document into an xf:instance explicitly to access the original
value. This seems utterly stupid to me but it would be possible as follows:
 
For example (this is in an XForms document called this.xfm):
 
<xf:instance id="foo">
    <x>500</x>
</xf:instance>
 
<xf:instance src="./this.xfm" id="this"/>
 
To access the original value of x in the foo instance, you would have to
xpath into the source document as follows:
 
instance('this')/x:html/x:head/xforms:model/xforms:instance[@id = 'foo']/x
 
But this is just silly. What's the deal with original values? If you needed
original values why not just load two versions of the instance??? Like:
 
<xf:instance id="foo">
    <x>500</x>
</xf:instance>
 
<xf:instance id="fooOriginal">
    <x>500</x>
</xf:instance>
 
 
 
<<
As I read the CR the instance() function is intended only to allow access to
the *copy* instance data which may or may not be the same as the original.
Do you read it that way too or have I missed something obvious?
>>

Yes, most definitely. But don't limit that only to the instance() function,
*ALL* XPath expressions are evaluated against the "copies". But they aren't
really copies, they are THE instance documents. There's not really originals
for each instance so the word copies is bad.
 
- Ryan
 
-----Original Message-----
From: AndrewWatt2001@aol.com [mailto:AndrewWatt2001@aol.com] 
Sent: Monday, November 18, 2002 3:06 PM
To: Tomayko, Ryan
Cc: www-forms-editor@w3.org; xforms@yahoogroups.com; www-forms@w3.org
Subject: Re: XForms CR - 7.10.1 Another XPath 1.0 Conformance Question


In a message dated 18/11/2002 19:20:11 GMT Standard Time,
Ryan_Tomayko@stercomm.com writes:




Andrew,

I am in no way the authority on this but I can give you one companies
interpretation on how this should be implemented. 

There are possibly many separate documents, and/or xpath data models (I'm
using the two interchangeably) that an XForms Processor maintains. Each
<xf:instance/> element defines a separate xpath data model. i.e. When an
XForms Processor comes across an xf:instance, it creates a new xpath data
model and either a.) loads the xpath data model from the uri specified, or
b.) loads the xpath data model from XML specified inline. 

Each data model is held separately and traversal from one data model into
either the source document, or other instance xpath data models, is
impossible with the base set of XPath axes and function library. For
example, assume I have 3 instances (i1, i2, and i3). If I am evaluating the
XPath expression ".." in i1, I do not get the <xf:instance/> element back as
a result, I get an error because I'm reaching for a parent that doesn't
exist. If I evaluate the XPath expression "/" in i3, I get back the root of
i3, not the root of the source document. In other words, it is impossible to
go outside of an individual instance data model. It is also impossible to
access the source document unless it is explicitly loaded into an instance.
(e.g. <xf:instance src="./this.xfm"/>).

This is where the instance() function comes into play. It allows me to
traverse into the root of some other instance's xpath data model, which
would be absolutely impossible otherwise. So, the instance() is NOT the id()
function, which seems to be how you've interpreted it.. The instance()
function is not limited to resolution within the context xpath data model. 

How the instance() function locates the xpath data model is an
implementation detail. For example, we use a HashMap to map instance id's to
DOM Document objects. The Map may contain any number of instance id's to DOM
Document mappings. When the instance() xpath function is called, the
function simply looks up the document in the HashMap and returns it.

Hope this helps,

- Ryan

-----Original Message-----
From: AndrewWatt2001@aol.com [mailto:AndrewWatt2001@aol.com] 
Sent: Monday, November 18, 2002 8:25 AM
To: www-forms@w3.org; www-forms-editor@w3.org; xforms@yahoogroups.com
Subject: XForms CR - 7.10.1 Another XPath 1.0 Conformance Question



This question is, for a short time, posted only to the three XForms lists. I

have other concerns about 7.10.1 which I will post separately.

It seems to me that the XForms CR may be using the instance() function and 
its related location paths in a way inconsistent with XPath 1.0.

I make the point in the assumption that John Boyer's recent email gives an 
accurate description of the relationship between instance data and the 
containing document. I am assuming that there is a *copy* of part/all of the

content of an <xforms:instance> element in a separate XPath data model.

There are background uncertainties since Micah Dubinko's recent post on 
XML-Dev is by no means clearly expressing the same meaning as John Boyer's 
email. Nor has the XForms WG responded to my question regarding the precise 
meaning of "instance data" and its scope.

My concern relates to the following syntax in the CR:
ref="instance('orderform')/shipTo/firstName"

The instance() function seems to me to reference the id attribute containing

the value "orderform". As I understand the situation that id attribute only 
exists in the original/containing document or, more precisely, in the XPath 
data model which represents it. As far as I understand it a representation
of 
that <xforms:instance> and its id attribute do not exist in the *copy* XPath

data model. Therefore the instance() function in the first location step of 
the quoted location path is referencing a node in the XPath data model of
the 
original/containing document.

However, again if I am understanding correctly, the two following location 
steps  reference *the copy* XPath data model (not the XPath data model of
the 
original/containing document).

So we seem to have a single XPath 1.0 location path apparently operating on 
two separate XPath 1.0 data models.

To the best of my knowledge that is inconsistent with XPath 1.0.

Andrew Watt





Hi Ryan,

Thanks for the reply.

With your current understanding of what the spec intends could you provide a
complete but short sample XForms "form" which your implementation will run
which uses the instance() function? 

Hopefully discussing an example might help us all refine where our existing
differences persist.

I agree with you that the implementation is, in a sense, a detail. My point
is that the XForms CR claims that the approach it takes is compliant with
XPath 1.0. As you probably realise I have yet to be convinced that that is a
true claim.

7.10.1 in the CR is not totally clear (at least to me). Do you think it is
possible to use the instance() function to reference the *original* value of
a piece of data contained in an <xforms:instance> element? If so, which
XPath expression could a document author use to achieve that?

As I read the CR the instance() function is intended only to allow access to
the *copy* instance data which may or may not be the same as the original.
Do you read it that way too or have I missed something obvious?

Regards

Andrew Watt 

Received on Monday, 18 November 2002 15:26:25 UTC