[xsl] accessing elements created on the fly

Subject: [xsl] accessing elements created on the fly
From: Dean Missikowski <dean_missikowski@xxxxxxxxx>
Date: Mon, 4 Jun 2001 20:59:32 -0700 (PDT)
Hi All,

I have some xml that arrives with elements containing
comma-delimited text like this:

However, I've written my XSLT transforms that generate
html based on input xml like this:

So, I've created the attached XSLT to convert the
comma-delimited <months></months> elements into
<month></month> elements.  

Being quite new to XSLT, I'm currently thinking I'll
have to perform the following two steps separately:

1. transform the original xml containing
<months></months> into xml using <month></month>
2. transform the xml from step 2 into html using the
XSLT designed to work with <month></month> elements

Is there any way to do both in one XSLT?  That is, can
the XSLT reference the elements created on the fly?
Ideally, I'd like to create an XSLT that I could
import into my XSLT that does the html transform so
that it the messy code that converts the
comma-delimited <months></months> elements does not
clutter up the xslt that does the html transform.



---- Source XML file ----
<?xml version="1.0" encoding="UTF-8"?>
	<client number="0000012345">

---- XSLT file used to convert <months></months>
elements ----
<?xml version="1.0"?>
	<xsl:import href="helper.xslt"/>
	<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
	<!-- Identity transformation template -->
  	<xsl:template match="@* | * | comment() |
processing-instruction() | text()">
	<!-- Convert <months>YYYYMM,YYYYMM,YYYYMM</months>"
elements to:
	<xsl:template match="months">
			<xsl:with-param name="text" select="text()"/>
			<xsl:with-param name="delimiter" select="','"/>
			<xsl:with-param name="element-name"


 ---- Source for helper.xslt ---- 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
		<xsl:param name="text"/>
		<xsl:param name="delimiter"/>
		<xsl:param name="element-name"/>
			<!-- if the passed in value contains the specified
delimiter... -->
			<xsl:when test="contains($text,$delimiter)">
				<!-- create an element using the specified element
name and the value preceding the delimiter -->
					<xsl:element name="{$element-name}">
				<!-- now recursively call this template again to
convert the remainder of the string -->
					<xsl:with-param name="text"
					<xsl:with-param name="delimiter"
					<xsl:with-param name="element-name"
			<!-- handle the last value -->
			<xsl:when test="$text != ' '">
				<xsl:element name="{$element-name}">
					<xsl:value-of select="normalize-space($text)"/>

Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

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

Current Thread