Instance fallback

https://www.w3.org/community/xformsusers/wiki/XForms_2.0#The_instance_Element


<instance> has two attributes for external content: the original @src, and 
the newer @resource.

An instance can also have inline content, and we define how the three 
interact as follows:

 The data for the instance is obtained from the link in the src attribute, 
if present and successful, otherwise from the inline content of the 
instance element if present, and otherwise from the link in the resource 
attribute.

1. With

 <instance src="saved.xml">
    <data xmlns="">
       <score>0</score>
    </data>
 <instance>

If saved.xml is readable, then that is used, otherwise the inline data.



2. Similarly, with

 <instance src="saved.xml" resource="init.xml">
    <data xmlns="">
       <score>0</score>
    </data>
 <instance>

If saved.xml is readable, then that is used, otherwise the inline data. 
@resource is never used.

3. With

 <instance resource="saved.xml">
    <data xmlns="">
       <score>0</score>
    </data>
 <instance>

Only the inline data is used.




4. With

 <instance src="saved.xml" resource="init.xml"/>


If saved.xml is readable, then that is used, otherwise init.xml.

I think 3. is a historical mistake, but is now part of our legacy.

However, explaining 1. in a lecture, it struck me that 'src' is not a very 
mnemonic name, and that @try would be a better name:


 <instance try="saved.xml">
    <data xmlns="">
       <score>0</score>
    </data>
 <instance>

 <instance try="saved.xml" resource="init.xml"/>

So proposal: deprecate @src, and introduce @try, but with the same meaning:

 The data for the instance is obtained from the link in the try attribute, 
if present and successful, otherwise from the inline content of the 
instance element if present, and otherwise from the link in the resource 
attribute.

Steven

Received on Thursday, 16 November 2023 15:54:46 UTC