OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] XQuery and DTD/Schema?

[ Lists Home | Date Index | Thread Index ]

*sigh* 

Numerous bugs abound in my XQuery expression, corrected version follows 

   schema "urn:xmlns:example-com" at
"http://www.example.com/schema.xsd"; 
   namespace ex = "urn:xmlns:example-com"
 
   define function get_children(element ex:root $r) 
      returns element ex:child*{
 
 	  $r/ex:child
   }
 
 
   get_children(<ex:root>{
 	 document("http://www.25hoursaday.com/root.xml";)//ex:child
 	          }</ex:root>)

-- 
PITHY WORDS OF WISDOM 
Lynch's Law: When the going gets tough, everyone leaves.

This posting is provided "AS IS" with no warranties, and confers no
rights. 



> -----Original Message-----
> From: Dare Obasanjo [mailto:dareo@microsoft.com] 
> Sent: Wednesday, July 03, 2002 12:54 PM
> To: Rick Jelliffe; xml-dev@lists.xml.org
> Subject: RE: [xml-dev] XQuery and DTD/Schema?
> 
> 
> You miss my point which is understandable since most people 
> don't have to deal with the aggravations of XML Query on a 
> daily basis. Here's an example of where type inferencing 
> breaks down. Given the following schema 
> 
> <xs:schema  targetNamespace="urn:xmlns:example-com" 
>          xmlns:xs="http://www.w3.org/2001/XMLSchema";
> elementFormDefault="qualified">   
>  <xs:element name="root">
>   <xs:complexType>
>    <xs:sequence>
>     <xs:element name="child" maxOccurs="3" />
>    </xs:sequence>
>   </xs:complexType>
>  </xs:element>
> </xs:schema>
> 
> And the following XQuery expression 
> 
>   schema "urn:xmlns:example-com" at 
> "http://www.example.com/schema.xsd"; 
>   namespace ex = "urn:xmlns:example-com"
> 
>   define function get_children(element of type ex:root $r) 
>      returns element of type ex:child{
> 
> 	  $r/child
>   }
> 
> 
>   get_children(<ex:root>{
> 	
> document("http://www.25hoursaday.com/root.xml";)//child
> 	          }</ex:root>)
> 
> How do you statically infer the type passed to the 
> get_children() function call? The correct answer is that you 
> can't. So what is the best workaround? Push it to a dynamic 
> evaluation like so 
> 
>  
> get_children(validate(<ex:root>{document("http://www.25hoursad
> ay.com/roo
> t.xml")//child}</ex:root>))
> 
> 	
> This example is relatively simple and could be made hairier 
> by adding substitution groups or derived types.
> 
> -- 
> PITHY WORDS OF WISDOM 
> Lynch's Law: When the going gets tough, everyone leaves.
> 
> This posting is provided "AS IS" with no warranties, and 
> confers no rights. 
> 
> 
> 
> > -----Original Message-----
> > From: Rick Jelliffe [mailto:ricko@allette.com.au]
> > Sent: Wednesday, July 03, 2002 12:38 PM
> > To: xml-dev@lists.xml.org
> > Subject: Re: [xml-dev] XQuery and DTD/Schema?
> > 
> > 
> > From: "Dare Obasanjo" <dareo@microsoft.com>
> > 
> > > Type inference can be ridiculously expensive and in some cases
> > > undecidable for complex types. Named typing and enforcing 
> explicit 
> > > casts by users via operations such as validate() are the 
> > best option
> > > in creating something reasonably implementable and
> > understandable. Of
> > > course, these things are only issues because XQuery is
> > supposed to be
> > > "statically typed"
> > 
> > Is inferencing always that difficult?
> > 
> > If we assume DTDs, then we have both a kind of Unique
> > Particle Attribute rule and no local elements or equivalents. 
> > If the DTDs were 
> > namespace aware and allowed declarations of the WXS builtin 
> > datatypes, it seems pretty trivial to annotate a query with 
> > the correct casts. 
> > 
> > If we have local elements, then the path in a query would
> > have to also be augmented with enough of a path to ensure 
> > locality, and other definitions of the same element name 
> > would have to be similarly augmented so they exclude the 
> > local element.
> > 
> > Presumably XQuery expects the Unique Particle Attribute rule,
> > then presumably it just means that the intersection of 
> > ambiguous elements in RELAX would have to be used. 
> > 
> > Cheers
> > Rick Jelliffe
> > 
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org
> > <http://www.xml.org>, an initiative of OASIS 
> <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
> 
> 




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS