This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: multiple child elements
hi jeni,
thanx for the response.
i didnt express what i was trying to acheive very well.
the XML file has the following structure which has more than one <synth> in
the root element hence my orginal <xsl:for-each select="kitlist/synth">
<kitlist>
<synth>
<manufacturer>Korg</manufacturer>
<model>Prophecy</model>
<name>Prophecy SOLO</name>
<year>199x</year>
<image>prophecy.gif</image>
<polyphony>1 note/Monophonic</polyphony>
<multitimbral>1 part</multitimbral>
<patches>256 (2 x 128)</patches>
<keys>37</keys>
<os>#20</os>
<midi>In, Out and Thru</midi>
<outputs>2 (1 x L/mono, R) headphones</outputs>
<synthesis>
<type>PCM</type>
<name>MOSS - Multi Oscillator Synthesis System</name>
</synthesis>
<sequencer>none</sequencer>
<description>
Despite it's limitations of being a monophonic instrument, this
machine is a powerful lead synth. Offering a total of 4 LFO's (Low
Frequency Oscillators) sounds can have a complex tonal texture. There are a
number of wave combinations to create sounds, some of these combinations
also allows real/physical instrument modelling.
</description>
<downloads>
<url name=""></url>
<url name=""></url>
</downloads>
<links>
<url name="korg.com">http://www.korg.com</url>
<url name="lfo4.com">http://www.lfo4.com</url>
</links>
</synth>
</kitlist>
the XSL stylesheet was only a snippet of the whole document, which style's
the other elements. when it encounters the multiple <url> child elements of
the <links> tag it only displays the first. is there a way of acheiving the
desired result other than giving each <url> tag a unique name ie. <url1>
etc... ?
assistance would be appriecated :)
sean
----- Original Message -----
From: "Jeni Tennison" <mail@jenitennison.com>
To: "Sean Kelly" <sean@allure.karoo.co.uk>
Cc: <xsl-list@lists.mulberrytech.com>
Sent: Sunday, September 09, 2001 11:57 AM
Subject: Re: [xsl] multiple child elements
> Hi Sean,
>
> > how do i display all the child elements from the XML file without
> > having to give each child a unique tag name?
>
> I assume that you want to generate something like:
>
> <a href="http://www.korg.com">korg.com</a>
> <a href="http://www.lfo4.com">lfo4.com</a>
>
> In other words, for each url element in your source document, you want
> to generate an a element whose href attribute is equal to the value of
> the url element and whose value is equal to the name attribute of the
> url element.
>
> Note that you want to generate an a element for each *url* element,
> so the xsl:for-each that you use should select the url elements, as
> follows:
>
> <xsl:for-each select="kitlist/synth/links/url">
> ...
> </xsl:for-each>
>
> As you had it, it selected the synth element, of which there is only
> one in your document, so you only got one a element.
>
> You can then generate the a elements for each of them similarly to the
> code that you demonstrated, but with the paths being relative to the
> url element rather than relative to the synth element; also I'd use an
> attribute value template rather than xsl:attribute, as follows:
>
> <xsl:for-each select="kitlist/synth/links/url">
> <a target="_blank" href="{.}">
> <xsl:value-of select="@name" />
> </a>
> </xsl:for-each>
>
> I hope that helps,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list