type-of() function and data type module

James Fuller <[email protected]>
Newsgroups gmane.text.xml.xslt.extensions
Organization Webcomposite
Message-ID <[email protected]>
Hello All,

EXSLT already has a facility to determine the type of an object e.g.
common module object-type(), though what is sorely lacking in XSLT 2.0
and XSLT 1.0 is the ability
to do a bit of 'duck typing'; e.g. in the form of a type-of() function
as initially proposed (i think) by Dimitre Novatchev in May 2005.

http://www.stylusstudio.com/xsllist/200505/post70520.html [1]

a type-of() function would return the type of the 'value' (not the
object), which can be useful in many scenarios.

So I am going to have a go at defining it though have a few additional
thoughts; should we contemplate a different module, perhaps related
specifically to data typing ? If so there maybe some knock on effects
e.g. we might think about moving object-type() to this.

So now stop reading now if u are sick of datatyping or schemas;

I have for years now toyed with the idea of defining an EXSLT datatype
module; not because I think I can come up with something better whats on
offer....more to provide an alternate sandbox/forum for all of us to
come up with something useful hopefully integrating existing
specifications such as XML Schema, RELAXNG, NRL, Schematron, etc....

I am more interested in lightweight aspects of data typing e.g. safety
to a certain degree (think simple validation), documentation...not to
mention the ease on my brain to immediately know what datatype an
element or an attribute by perhaps looking at a type attribute (ala XML
Schema primative datatypes though we could attempt to clean up the mess
that is anyURI or add scie)..as well as the option to eschew with using
datatypes if I choose (no strong typing required).

Let me first assert that I am firmly 'on the fence' when it comes to the
use of weak or strong typing especially when set within overly complex
schema specifications such as XML Schema. Admittedly inertia and time is
making XML Schema bearable, though I think I can safely predict that
there will never be an XML Schema 2.0 and XML Schema 1.1 wont fix what I
think is broke with it. Perhaps its just something I need to accept and
just move on.

Schematron approach based on assertions represents to me the most
'useful' approach when solving real world problems. Though, it
highlights a problem with most of the various schema technologies, that
there is no real thought of how to make an xml instance 'standalone'
that is I would like to relate assertions and data types in the instance
xml....use XML Schema primative datatypes u say.....yes these are useful
(and I use them), though I would like to explicitly link xml instance
data to an assertion using an attribute.

Other approaches, albeit much simpler (RELAX NG) are still as
frustratingly incomplete (co-constraints anyone) though this is my
standard schema technology of choice when performing commercial
work...it still suffers from low rates of adoption and presence in major
toolsets.

I think its insane to ignore the obvious benefits with respect to
documentation and safety obtainable using even primative datatypes, so
along with having a stab at type-of() I will start something in the
sandbox for a data-type module;

* come up with a set of simple data types, using XML Schema datatypes as
a guide...cleaning up things like anyURI along the way, as well as
adding support for scientific data types. Perhaps we use some DTD
conventions for cardinality and for defining ranges/lists along the way
(type:integer="*,1-5" or type:integer="xs:integer".....wild stabs at the
moment).

* come up with a standard way of linking schema definitions with
instance xml data, which provides just enough information in the
instance data for some developer/system to grok the data type (and/or
follow a reference to look it up) and to assist documentation.

* investigate where things such as Namespace Routing Language is going
and if there is any place for such high level process control within
such a module

Ahhh, so something with the depth (and critical thinking) of XML Schema,
simplicity (brevity and comprehension) of RELAX NG, combined with the
ability to perform assertions ala Schematron. Sprinkle the facility to
apply regular expression (XSLT 2.0) checking, add a dash of future
proofing and process control aka Namespace routing language(NRL) and
thats something I would use day in, day out for a long time to come.

I am by far no expert in this field; would welcome any corrections to my
thinking etc...

cheers, Jim Fuller

[1] http://www.stylusstudio.com/xsllist/200505/post70520.html :  funnily
enough Dimitre alludes in this May 2005 email to inactivity (death) of
EXSLT, which I think can be directly attributed to the fact that we
(well I for one) was waiting for what form XSLT 2.0 would take...now
that its current form looks set to remain the same, I think EXSLT can
now do its thing again.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.