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

Re: iterating a nodeset (provided by XML or XSL) in a

Subject: Re: iterating a nodeset (provided by XML or XSL) in a custom template (image-chooser)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 9 Apr 2003 11:12:50 +0100
iterating xpath
> I am looking for a template that iterates over a given set (of nodes
> describing images) and picks a right one based on criteria (e.g. img width<display
> width.... ;-) )

Depending on exactly what the test is, you don't need a template for
that, just an Xpath predicate, eg if $set is a set of <img/> nodes

$set[@width &lt; $displaywidth]

is the subset of that set with width attribute less than the
$displaywidth variable.

> but with that code, the instructions from <xsl:template name="header-image">
> were simply copied, not applied.
No the instructions in teh template will have been applied, but without
seeing the template it's hard to say why you did not get what you
expected.


  - in general, how can I _build_ a nodeset in an XSL template and pass it as
  a parameter xsl:call-template? (and what's the best way to process that
  nodeset?)

If you are actually constructing nodes then you can not do this in XSLT
1 without a node-set extension function to convert the result tree
fragment back to a node set, but I do not think you are doing that here,
you are not building new nodes, just getting them from the source or the
stylesheet. Actually it's probably a bit easier to have your other image
documents not directly in your xsl file but in a sibling xml file that
you bring in via document() 

> I'm not sure how work through a list of images.

if you have some <img/> elements  in the main source file and some in a file say
defautimage.xml then you can just

<xsl:apply-templates 
  select="/some/path/to/img | document('defautimage.xml')/some/other/path/to/img"/>

will apply templates to images in your input document and your
defautimage.xml file.
However you have to decide what the Xpaths need to be based on teh
structure of your input.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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


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.