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

Re: Selecting Elements fo processing

Subject: Re: Selecting Elements fo processing
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Sat, 05 Oct 2002 14:10:56 +0200
j rg nickolay
Hello Nickolay,

did you look at any tutorial or in any book? This is a question about the basics of XSLT.

<xsl:template match="root">
  <table border="1">
    <tr>
      <td>type</td>
      <td>features</td>
      <td>price</td>
    </tr>
    <xsl:apply-templates select="item"/>
  </table>
</xsl:template>

<xsl:template match="item">
  <tr>
    <xsl:apply-templates select="*"/>
  </tr>
</xsl:template>

<xsl:template match="car | potatoes">
  <td>
    <xsl:value-of select="name()"/>
  </td>
  <td>
    <xsl:apply-templates select="*"/>
  </td>
</xsl:template>

<xsl:template match="maxspeed | colour | quality | pack">
  <p><xsl:value-of select="name()"/>: <xsl:value-of select="."/></p>
</xsl:template>

<xsl:template match="price">
  <td><xsl:value-of select="."/></td>
</xsl:template>

The next time please read in FAQs or tutorials first.

http://www.dpawson.co.uk/xsl/sect2/sect21.html
http://www.zvon.org/xxl/XSLTreference/Output/index.html
http://www.zvon.org/xxl/XSLTutorial/Output/index.html

Regards,

Joerg

Nickolay Kolev wrote:
Hi all,

I want to process something similar to:

<item>
	<car>
		<maxspeed>120</maxspeed>
		<colour>red</colour>
	</car>

<price>1000</price>

</item>

<item>
	<potatoes>
		<quality>1</quality>
		<pack>10kg</pack>
	</potatoes>

<price>50</price>

</item>

so far I have:

<xsl:for-each select="item">
	<p><xsl:value-of select="price" /></p>
</xsl:for-each>

for getting the price element which is common to all items...

But how do I write:

if child element is car print "maxspeed is XXX and the colour is YYY"

else if child element is potatoes print "quality is XXX and the origin is YYY"

else if ...

else ...

I hope I have made myself clear.

Many thanks in advance,
nmk


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





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.