[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Benefits of xsd-types in XSLT
> We often hear that one of the great benefits of using XSLT > 2.0 is that it uses the datatypes of XML Schema, most likely > the same datatypes as input XML and output XML, making type > conversion not necessary. > > But how great a benefit is it really? Well, there are a number of benefits. Firstly, there are many functions and operators defined on these types - for example all the date and duration logic depends on them. Of course, this doesn't mean that you have to use a schema; so long as your values use the lexical forms of these types, you can always hand-construct the values; but if you do have a schema, it is done for you. Secondly, there is type-checking. Some operations don't make sense when applied to the wrong type of value. With type-checking, your errors are diagnosed earlier and more precisely, making development faster, and making the reliability of your code less dependent on the completeness of your test coverage. And then there is polymorphism. Comparing "1.2" and "10.2" as strings is not the same as comparing them as decimals. Finally, there is optimization. If the system has more compile-time information about types, then it can make decisions at compile-time that would otherwise be deferred to run-time, which enables it to generate tighter code. But really, you're asking here about the benefits of strong typing versus weak typing. That's a big debate and you'll get different opinions. The bottom line is that strong typing finds more of your errors at compile time, and it also enables the compiler to make more decisions at compile time. > E.g.: when using XML > data binding, the XML Schema datatypes are, as far as I know, > automatically converted to the type system of C#, Java, etc. I've lost the thread here. I thought we were talking about types as used in XSLT. Where does data binding come into it? > I would like to hear some real life cases, showing that > xsd-datatypes in XSLT can be a great time-saver when input > and output is strongly typed also using XSD, compared with > more traditional programming languages? I'm not sure from this what two things you want to compare - sorry! (Some traditional programming languages are strongly typed, others aren't - which did you have in mind?) Regards, Michael Kay http://www.saxonica.com/ http://twitter.com/michaelhkay
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|