[Bug 3771] [FS] technical: interleaved with empty text nodes

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3771





------- Comment #15 from jmdyck@ibiblio.org  2008-05-14 08:10 -------
In order to properly support the uses of fs:item-sequence-to-node-sequence
in sections 4.4.1 Insert and 4.4.3 Replace of the XQuery Update CR (see
Bug 5666 comment #0), I propose the following tweak to the above fixes.

Recall that the semantics of fs:B are:
  1) Replace each document node by its children.
  2) Merge adjacent text nodes, delete empty text nodes.
  3) Raise an error if an attribute node follows a non-attribute node.

The starting point for the tweak is to move step 1 from fs:B up to fs:A.
(This is valid because fs:B encounters a document node if and only if
fs:A emits one, and because the replacement is context-independent.)
So fs:A's output type no longer includes 'document', which means
that fs:A's static typing now achieves all the type-transforms that
fs:B(fs:A(...)) used to. Which means that fs:B now has no real need
to appear in the normalized query, and can instead dissolve into the
dynamic semantics of computed element constructors. Note that those
semantics already enforce step 3, so the only thing left is for them
to handle step 2.

So, here is the tweaked version of the fix in comment #8.  (I assume
that fs:A inherits the name fs:item-sequence-to-node-sequence.)

4.7.1 Direct Element Constructors / Norm / rule 3
    Delete fs:item-sequence-to-node-sequence and all the parens.
    Delete the interleaved text{""} items.

4.7.1 Direct Element Constructors / Norm / rule 8
    Change to:
        [[ { Expr } ]]_ElementContentUnit
        ==
        fs:item-sequence-to-node-sequence(( [[ Expr ]]_Expr ))

4.7.3.1 Computed Element Constructors / Dyn Ev / rule 1+2
    After
        statEnvn; dynEnv |-  Expr0 => Value0
    insert
        Value0 with text nodes prepared is Value1
    and change subsequent occurrences of Value0 to Value1.

    The latter is an informally defined auxiliary judgment that implements:
        Merge adjacent text nodes; delete empty text nodes.

7.1.5 The fs:item-sequence-to-node-sequence function
    Change its STA as follows:

    For brevity here, I leave out the "statEnv |-" and use the following
    abbreviations:
        Child_Type -> (element*|text|processing-instruction*|comment)
        A(Type)    -> (FS-URI,"item-sequence-to-node-sequence")(Type)

    The STA rules would be:

        Type   <: attribute**
        ---------------------
        A(Type) : attribute**

        Type   <:              (Child_Type|document|xs:anyAtomicType)*
        --------------------------------------------------------------
        A(Type) :               Child_Type*

        Type   <: attribute**, (Child_Type|document|xs:anyAtomicType)*
        --------------------------------------------------------------
        A(Type) : attribute**,  Child_Type*


And here's the tweaked version of the fix for document constructors in
comment #13,

4.7.3.3 Document Node Constructors / Norm / rule 1
    Change
        fs:item-sequence-to-node-sequence-doc
    to
        fs:item-sequence-to-node-sequence

4.7.3.3 Document Node Constructors / Dyn Ev / rule 1+2
    Insert a premise of the form
        ValueX with text nodes prepared is ValueY
    as appropriate.

7.1.6 The fs:item-sequence-to-node-sequence-doc
    Drop the section.

========================================================================

With the above changes, the references to fs:item-sequence-to-node-sequence
in XQuery Update sections 4.4.1 Insert and 4.4.3 Replace would become correct,
both statically and dynamically.

Received on Wednesday, 14 May 2008 08:10:34 UTC