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

Re: Iterate through variable in XSLT?

Subject: Re: Iterate through variable in XSLT?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 20 Aug 2007 11:19:09 -0400
Re:  Iterate through variable in XSLT?
Hi Yun Wu,

At 04:07 AM 8/18/2007, you wrote:
basically i like to generic produce the following code rather then write it by myself

<xsl:template match="/">
   <xsl:attribute name="name">
   <xsl:attribute name="name">
   <xsl:attribute name="name">
   <xsl:attribute name="name">

It isn't exactly clear what you actually want. For one, your example isn't well-formed. I am going to assume you want:

  <xsl:attribute name="name">

... that is, you want to attach a series of class elements each with an attribute named "name" and a value "classX".

Then the next question is will it be simply

<class name="classX"/>

? if so, this is just generating a series of elements matching a series of values.

Given a series of values X:


then generating the source is pretty easy stuff, as you can undoubtedly see: you simply select the set of nodes x/* and generate 'class' elements, populating their @name attributes accordingly:

(Having bound $values to x/value, depending on the context)

<xsl:for-each select="$values">
  <class name="{.}"/>

The only question remaining is how you want to make x/value available at runtime. There are many ways to do this; which is most convenient depends on your processing architecture.

So you probably need to pose a more specific question, correcting any mistaken assumptions in the above. My guess is you want to do something more complex, and/or you're actually asking about ways to make an arbitrary series of values available at runtime (i.e., how to bind a $values variable).

An external document called in with the document() function may be the simplest and most versatile way to do this.


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread


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