[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Types and Context

  • From: Jonathan Borden <jborden@m...>
  • To: Gavin Thomas Nicol <gtn@e...>, xml-dev@l...
  • Date: Mon, 21 May 2001 20:14:26 -0400

types of context
Gavin Thomas Nicol wrote:

> > <p:book>
> >   <title />
> >   <genre/>
> >   <author>
> >     <title/>
> >     <familyName/>
> >   </author>
> > </p:book>
> >
> > Then how do you distinguish between the two title elements?
>
> Context.

Exactly. And if you stop to think about this, XML Schema "datatypes"  are
hardly going to revolutionize XSLT/XPath 2.0.

Gasp! I hear cries of "no, no, no" echoing around the web...

In the Schema Algebra [1] statements [7-9] a "type" is the property of
belonging to a class. The predicate "typeOf(x, c)" tests a node "x" for
membership in the instance set of the class "c".

Think about XSLT templates, a template matches an XPath selector returning a
_set_ of nodes. This selector is seen directly as a _type_ which is defined
based on _context_. XML Schema may use rules other than context to classify
a node as a type, but this basic capability is one we already know and use
in XSLT/XPath.

Now let's think about one of the given examples:

"
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
           xmlns:this='urn:example.org.people'
           targetNamespace='urn:example.org.people' >

  <xs:complexType name='person' >
    <xs:sequence>
      <xs:element name='given' type='xs:string' />
      <xs:element name='family' type='xs:string' />
    </xs:sequence>
  </xs:complexType>

  <xs:element name='person' type='this:person' />

</xs:schema>
"

which would be used with a snippet such as:

<this:person xmlns:this='urn:example.org.people'>
  <family>Gudgin</family>
  <given>Martin</given>
</p:martin>

Now how might we refer to the _type_ of the <family> element. In XML Schema
terms the _type_ of the "this:person" element is "this:person" ... this is
also the XML 1.0 type as in XML 1.0 an element's type is its name, so far so
good.

What about the <family> element. In XML Schema, this element is declared in
the "this:person" complex type so you might use an XPath expression:

"this:person/family"

to refer to the "XML Schema datatype" in this new PSVI world (actually in
the XML Schema Formal Language it would be something like
"urn:example.org.people::type(person)::element(family) but assume the above
is shorthand)

... turns out that this is _exactly_ the same as the XPath used as an XSLT
selector. So I guess the real utility of XML Schema datatypes is the ability
to say: "use this QName as shorthand for this path selector".

Context.

-Jonathan


[1] http://www.rddl.org/SchemaAlgebra


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.