<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>3946</bug_id>
          
          <creation_ts>2006-11-02 18:17:04 +0000</creation_ts>
          <short_desc>[FS] Typing of processing-instructions</short_desc>
          <delta_ts>2008-07-15 05:46:31 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Formal Semantics 1.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nick Jones">nick</reporter>
          <assigned_to name="Michael Dyck">jmdyck</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>12790</commentid>
    <comment_count>0</comment_count>
    <who name="Nick Jones">nick</who>
    <bug_when>2006-11-02 18:17:04 +0000</bug_when>
    <thetext>We are looking at ForExprType060 and ForExprType061 in XQTS which are

for $test as processing-instruction(&quot;filesystem&quot;) in ($input-context//fs:Folder)[1]//processing-instruction()
return $test

and

for $test as processing-instruction(&quot;unknown&quot;) in ($input-context//fs:Folder)[1]//processing-instruction()
return $test

one if which is meant to throw a type exception, the other not, as all processing instructions nodes are &lt;?filesystem?&gt;. But I don&apos;t believe the formal semantics describe this behaviour.

The normalization rules in 3.5.4 state

[processing-instruction(StringLiteral)]sequencetype == processing-instruction?


Static typing in 4.8.2:

statEnv |-  Expr1 : Type1
Type0 = [ SequenceType ]sequencetype
statEnv  |-  prime(Type1) &lt;: Type0
statEnv |-  VarName1 of var expands to Variable1
statEnv + varType(Variable1 =&gt; Type0)  |-  Expr2 : Type2
statEnv |-  for $VarName1 as SequenceType in Expr1 return Expr2 : Type2 · quantifier(Type1)

passes for the above expressions as the types are Type0 and prime(Type1) are both processing-instruction


For dynamic evaluation 8.3.1 Matches states

statEnv |-  processing-instruction NCName { String } matches processing-instruction

and 

statEnv |-  Value matches (Type | empty)
statEnv |-  Value matches Type?


as I believe according to the formal semantics all processing instructions match processing-instruction(&quot;anything&quot;).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>14190</commentid>
    <comment_count>1</comment_count>
    <who name="Jim Melton">jim.melton</who>
    <bug_when>2007-02-26 00:08:05 +0000</bug_when>
    <thetext>The fix for this bug does not appear in the Recommendation of 23 January 2007.  It will be considered for a future publication (either an Errata document or some possible future version of the specification). </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15035</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2007-05-08 02:06:38 +0000</bug_when>
    <thetext>(personal response)

I agree, the Formal Semantics does appear to be wrong in this respect.

Proposed solution:

A)
The formal type system must model the target of a PI. In analogy to ElementType and AttributeType, we can define (in 2.4.2 Item types, duplicated in A.2):
    [? (Formal)] ProcessingInstructionType ::=
                     &quot;processing-instruction&quot; PITargetOrWildcard
    [? (Formal)] PITargetOrWildcard ::= NCName | &quot;*&quot;

In [27 (Formal)] ElementContentType, replace
    &quot;processing-instruction&quot;
with
    ProcessingInstructionType

B)
Except as handled otherwise below, wherever
    processing-instruction
appears as a type, replace it with
    processing-instruction *

Specifically, that would be in:
    3.5.1 / example 1,7
    3.5.4 / Norm / rule 17,18,19,20,25,26
    4.7.3.1 / STA / rule 1,2,3,4
    4.7.3.1 / DEv / rule 1,2
    4.7.3.3 / DEv / rule 1,2
    4.7.3.5 / STA / rule 2
    7.1.5 / STA / rule 1
    7.1.6 / STA / rule 1
    7.2.5 / STA / rule 3,4
    7.2.6 / STA / rule 6
    8.1.7 / Sem / rule 1,2
    8.2.2.1.3 / Sem / rule 8,9
    8.2.2.1.4 / Sem / rule 6
    8.2.2.1.5 / Sem / rule 3
    8.3.1 / Sem / rule 4

C)
In 3.5.4 / Norm, delete the paragraph beginning &quot;The [XPath/XQuery] type system does not model the target of a processing-instruction&quot;, and replace the two subsequent rules (21 &amp; 22) with:

    [[ processing-instruction(NCName) ]]_sequencetype
        ==
    processing-instruction NCName

    StringLiteral has atomic value String
    xs:NCName(String) = NCName
    --------------------------------------------------------
    [[ processing-instruction(StringLiteral) ]]_sequencetype
        =
    processing-instruction NCName

D)
In 4.7.3.5 / STA / rule 1 / conclusion, change the type to
    processing-instruction NCName

E)
In 8.2.3.1.2 / Sem 4 (Processing instruction, comment, and text kind tests), replace rule 1 with:

    [[ PITest ]]_sequencetype = processing-instruction *
    -----------------------------
    statEnv |- test PITest with PrincipalNodeKind
               of ProcessingInstructionType
               : ProcessingInstructionType

And replace rule 2 with:

    [[ PITest ]]_sequencetype = processing-instruction NCName
    -----------------------------
    statEnv |- test PITest with PrincipalNodeKind
               of processing-instruction NCName
               : processing-instruction NCName

    [[ PITest ]]_sequencetype = processing-instruction NCName
    -----------------------------
    statEnv |- test PITest with PrincipalNodeKind
               of processing-instruction *
               : processing-instruction NCName ?

F)
In 8.3.1 / Sem, after rule 4, insert

    statEnv |- processing-instruction NCName { String }
               matches processing-instruction NCName</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15093</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Rys">mrys</who>
    <bug_when>2007-05-15 16:09:33 +0000</bug_when>
    <thetext>Here is an earlier discussion (member only) on this topic: http://lists.w3.org/Archives/Member/w3c-query-editors/2003Oct/0052.html 

Best regards
Michael</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>16135</commentid>
    <comment_count>4</comment_count>
    <who name="Jerome Simeon">simeon</who>
    <bug_when>2007-08-13 19:17:40 +0000</bug_when>
    <thetext>Note that any resolution of this issue may also be reflected on the Static typing feature in the Update facility document (see Bug 4832).
- Jerome</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>17885</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2007-11-28 23:43:34 +0000</bug_when>
    <thetext>At its meeting on November 27th, the Joint XML Query WG and XSL WG approved the solution presented in Comment #2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>21183</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-07-15 05:46:31 +0000</bug_when>
    <thetext>This issue has been entered as FS erratum E022, and its fix has been committed to the source files for the next edition of the FS document.
Consequently, I&apos;m marking this issue CLOSED.
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>