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

Re: A beef with XSLT Sometimes too complicated

Subject: Re: A beef with XSLT Sometimes too complicated
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 14 Jul 2006 13:41:43 +0100
xslt mode
 <xsl:variable name="x" 
    select="if $var then select(@id='1') else select (@id='2')"/>
  <something id="1">
     hello!
  </something>
  <otherthing>
     goodbye
  </otherthing>


actually I can't guess what the intended semantics of that are.
I can guess you mean to define $x to be one of those elements, but where
would control flow after the xsl:variable? On the face of it it would
produce both the elements in teh result as they are literal result
elements.

In XSLT2 you can more or less arbitrarily mix xslt and xpath code by way
of xslt functions.

<xsl:function name="x:f">
 <xsl:param name="here"/>
 <xsl:apply-templates select="$here/a"/>
</xsl:function>

<xsl:function name="x:g">
 <xsl:param name="here"/>
 <xsl:apply-templates select="$here/b"/>
</xsl:function>

<xsl:value of select="if (foo) then x:f(.) else x:g(.)"/>

obviously the functions can be any xslt construct, template calls,
for-each instructions, whatever.

This is basically how xq2xml works. As Mike just mentioned XQuery is
more naturally compositional than XSLT, you can nest expressions much
more freely, so when converting to XSLT, xq2xml is either in xslt mode
or xpath mode. If its in xslt mode and needs to generate some xpath, it
generates a select=..." attribute and then switches to xpath mode.
Conversely if its in xpath mode and needs to generate some xslt (to
generate element nodes, or execute xsl:for-each, usually) then it puts
all the generated xslt in a function body, and puts the function call in
the xpath expression.

David

Current Thread

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
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.