Re: FW: a strange thing about attribute in type inference(whit example)

Phenix,

As pointed out in the introduction of the section, the semantics of
attribute and element constructors is still under development. Many
parts of the specification of constructors will be revised in the next
working drafts.

With regard to your problem, there are several remarks:

 - You need to take the normalization of the path expression inside the
attribute into account. XPath is often performing implicit access to the
content of an element or attribute, like in the following expression:

 $b/@year + 2

which adds the integer 2 to the content of attribute @year.

This is dealt with in XPath 2.0 and XQuery 1.0 specifiction through
normalization. (See section 4.3 of the Formal Semantics document).

 - Assuming we do implicit access to the content of the attribute, the
normalization of your expression would look like:

 for $x1 in (for $dot in $b return attribute::year)
 return
  attribute year {
   (typeswitch $x1
     case atomic? return  $x1
     case node return
       typeswitch data($x1) as $x2
            {--   ^^^^^^^^^  note the use of the data accessor   --}
         case atomic? return  $x2
         default return  dm:error()
     default return  dm:error())
  }

Where the data() accessor is used to access the typed value of the
attribute.

 - The mapping I give above is an open issue, as the semantics of
attribute and element constructors is still under discussion by the
working group. In case there is no implicit access to the typed content,
your analysis would be correct and the query would result in a type
error. In that case, the user would have to write explicitely something
like: <book year={ data($b/@year) } ....

 - You can see the corresponding query (XMP use case query 1).
and mapping to the XQuery core on the Galax demo at: 

 http://db.bell-labs.com/galax/
 

Hope this helps,

Jerome Simeon -
Bell Laboratories --- Lucent Technologies
600 Mountain Avenue, Murray Hill, NJ, USA
Tel: +1 908 582 5473 Fax: +1 908 582 7308


> -----Original Message-----
> From: Phenix Shieh [mailto:phenix_shieh@hotmail.com] 
> Sent: Saturday, April 06, 2002 10:10 AM
> To: www-xml-query-comments@w3.org
> Subject: a strange thing about attribute in type inference(whit example)
> 
>  
> 
> When I tried to go-through the FS document,a strange occured. What I used was founded in UseCase Doc.:
> 
> <book year={$b/@year} <mailto:year=%7b$b/@year%7d%3e...%3c/book> >...</book>
> 
> As the FS said,this element constructor should be normalized into computed element construtor.So,it should be rewriten like this:
> 
> element book{
> 
>    attribute year {$b/@year <mailto:%7b$b/@year> },
> 
>    ...
> 
> }
> 
> I focused this line:attribute year {$b/@year <mailto:%7b$b/@year> }.
> 
> As the rule says:
> 
> /////////////////////////////////////////////////////////////////
> 
> statEnvs |- expand(QName) = qname  
> statEnvs |- ExprSequence : Type1  
> Type1 <: xs:AnySimpleType
> --------------------------------- 
> statEnvs |- attribute QName { ExprSequence } : attribute qname { Type1 }  
> 
>                   
> 
>                  +++ RULE 1+++
> /////////////////////////////////////////////////////////////////
> 
> The ExprSequence is "$b/@year" and the QName is year.
> 
> I had set a statEnvs that $b has the type:
> 
> element book{
> 
>   attribute year {xsd:integer},
> 
>   ...
> 
> }
> 
> After some caculate(do as the FS told me),the type of "$b/@year" is :
> 
> attribute year{ xsd:integer}
> 
>  
> 
> So,Type1 in RULE1 is :
> 
> Type1=attribute year{ xsd:integer}
> 
>  
> 
> Using all these in RULE1,I either got the result:
> 
> attribute year { attribute year {xsd:integer} }
> 
> or the RULE1 must not be used because Type1 was not the subtype of xs:AnySimpleType(how should i do in this case?).
> 
>  
> 
> The wannted result is:
> 
> attribute year { xsd:integer}
> 
>  
> 
> Here the wrong was!
> 
>  
> 
> Perhaps we need another rule to solve this problem.
> 
> May I'm wrong since I only read the new FS only one time.But i will be appreciated if someone can explain this strange thing.
> 
> PS:I cannot visit the mail listing archive,so email reply is warmly welcomed.:-P
> 
>  
> 
> 
>   _____  
> 
> 从网站得到更多信息。MSN Explorer 免费下载:http://explorer.msn.com/lccn
> 
> 

Received on Monday, 8 April 2002 11:24:21 UTC