Forum Moderators: phranque

Message Too Old, No Replies

XML and XSL

how the heck...?

         

httpwebwitch

8:08 pm on Nov 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have some XML (which I can not control, it's fed to me), and I want to format it using XSL.

My XML looks kinda like this:

<things>
<doodads>
<grommit type="plastic"/>
<grommit type="metal" />
<grommit type="wood" />
<grommit type="silly putty" />
</doodads>
</things>

What I need to do is display something like this:
- my plastic grommit
- my metal grommit
- my wood grommit
- my silly putty grommit

Ideally I'd like this XSL to work on the server, so I can use ASP to transform it:
xml.transformNode(xsl)

I've been hacking through tutorials on the <xsl:for-each > and <xsl:value-of> for a long time, and still nothing is working. I'm at my wit's end.
HELP!

Hester

3:19 pm on Nov 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you looked at the examples in this tutorial?

[w3schools.com...]

Alternative Future

3:32 pm on Nov 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello httpwebwitch,

Is it something like this you are looking for?

<xsl:for-each select="doodads/grommit">
- my <xsl:value-of select="@type"/> grommit<fo:block/>
</xsl:for-each>

This example goes on your <things> being the report-root and your document starting with <xsl:template match="things">

-George

choster

3:43 pm on Nov 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What is the context? For instance, it might be better to use

<xsl:template match="things">
<ul>
<xsl:apply-templates select="doodads/grommit" />
</ul>
</xsl:template>

<xsl:template match="grommit">
<li>
<xsl:text>my </xsl:text>
<xsl:value-of select="@type" />
<xsl:text> grommit</xsl:text>
</li>
</xsl:template>

httpwebwitch

8:04 pm on Nov 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A-F's suggestion worked. Thanks so much!