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

Re: Pete's blend for XMLlite

  • From: "Pete Cordell" <petexmldev@codalogic.com>
  • To: "Michael Kay" <mike@saxonica.com>,<xml-dev@l...>
  • Date: Thu, 9 Dec 2010 13:00:51 -0000

Re:  Pete's blend for XMLlite
Original Message From: "Michael Kay"

> One thing I'd like to bring in from the JSON world is some basic duck 
> typing.
> <person age=90 dob=1920-03-04 name="Ronald" retired=true 
> children=["Barbara", "Michael"]/>
> There's no need for a DTD or schema to do simple type annotation.

I'm not convinced that the typing in JSON is a key feature.  If you don't 
know what a 'wibble' is, knowing it is an integer doesn't really help you 
much.  I think it's an artifact of JSON being based on Javascript that it 
has these different forms for integers vs. strings etc.  A program does need 
to know whether something is an integer.  A transfer format just needs to 
get across the wire some suitable representation of wibble that a program 
can use.  As part of knowing how to deal with a wibble, the program knows 
that a wibble is an integer.

I would say your sample is fairly exlicit typing.  (I guess there is 
ambiguity around whether 'age' is an integer, float or decimal.)  But I 
think duck typing would work pretty much as well if you had regular XML:

<person age='90' dob='1920-03-04' name="Ronald" retired='true'
children='["Barbara", "Michael"]'/>

In the case of Javascript it would be sensible to duck type age to a number 
as it doesn't need much provocation to convert a number to a string.  For 

var json = { "Int" : 12, "Int2" : 14 };
var result = "The sum is: " + json.Int + json.Int2;
document.write( result );


The sum is: 1214

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.
First Name
Last Name
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.