XSLT 2.0 Typing (Was: RE: [xsl] Re: XSLT 2.0: On xsl:sequence and xsl:copy-of )

Subject: XSLT 2.0 Typing (Was: RE: [xsl] Re: XSLT 2.0: On xsl:sequence and xsl:copy-of )
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 13 Oct 2003 06:31:37 -0700 (PDT)
> Ok. So (and I think I've asked this before and Mike quoted ?I think?
> xsd rec) where is the full list of ' data types' in the current raft of
> specs?
> http://www.dpawson.co.uk/xsl/rev2/exampler.html#iof
> lists the ones I guessed at.
> > I couldn't find one, so I guess as with Dimitres 'misnaming',
> > I (we?) will be fumbling with data types until we've guessed them all?
> > 
> > 
> > >  
> > >  > the anonymous type?
> > >  
> > >  Your getting your terminology confused 
> > 
> > Yes, you're probably right Jeni... but I'm not surprised,
> > its got to be closer to xsl-fo complexity than xslt 1?
> > 
> > Not getting at you Jeni, honest.

In XSLT, as in other programming languages, typing can be very useful.

I personally have already benefitted by XSLT 2.0 typing. In particular, it
allows me to eliminate code, which in XSLT 1.0 was necessary, e.g. to
check if a node-set passed as parameter is empty and then issue an error

Instead of:

<xsl:template name="foldl1">
  <xsl:param name="pFunc" select="/.."/>
  <xsl:param name="pList" select="/.."/>

     <xsl:when test="not($pList)">
      <xsl:message terminate="yes">Some strong words!!!</xsl:message>
     <xsl:otherwise>useful code here</xsl:otherwise>

I now can simply write:

<xsl:function name="f:foldl1">
  <xsl:param name="pFunc" as="element()"/>
  <xsl:param name="pList" as="item()+"/>

  <!-- useful code here -->

This is a significant reduction of the complexity of the code and the
total number of lines. As result the code is simpler, more easier to write
and understand, programmer productivity is increased.


Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread