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

Simple Xsl Problem

Subject: Simple Xsl Problem
From: Nischal <nischal_muthana@xxxxxxxxx>
Date: Sun, 9 Nov 2003 13:59:23 -0800 (PST)
simple xsl
Hi All

I have an xml file like the following:

<Parent>
  <Orders>
    <Order1>
	<ItemName>TV</ItemName>
	<ItemModel>Sony</ItemModel>
	<ItemPrice>423424</ItemPrice>
    </Order1>
    <Order1>
	<ItemName>VCR</ItemName>
	<ItemModel>Mitsubishi</ItemModel>
	<ItemPrice>1233213</ItemPrice>
    </Order1>
    <Order2>
	<ItemLocation>San Francisco</ItemLocation>
	<ItemTime>200310101010</ItemTime>
    </Order2>
    <Order3>
	<ItemPrice>1000</ItemPrice>
    </Order3>
  </Orders>
</Parent>

I trying to build a generic xsl transform which would
pick up all the unique Orders(Order1's, Order2's and
Order3's and so on...) and build a table like below.

Order1
ItemName   ItemModel   ItemPrice
  TV          Sony       423424
  VCR      Mitsubishi    1233213

Order2
ItemLocation     ItemTime
San Francisco    200310101010

Order3
ItemPrice
1000

All of this I am trying to build a generic xsl
template. 

Questions:

1. I wasn't able to get the unique node names and get
the child nodes to print out them.

Can someone help me in how to approach this.

Here is my stupid xsl I started off with and got
stuck.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
   <xsl:variable name="Test"
select="/Parent/Orders/*"/>
   <xsl:call-template name="Test">
    <xsl:with-param name="OrderName" select="$Test"/>
   </xsl:call-template>
</xsl:template>
<xsl:template name="Test">
   <xsl:param name="OrderName"/>
      <xsl:for-each select="$OrderName">
	<p>
       <xsl:variable name="pos" select="position()" />
     <xsl:choose>
       <xsl:when test="not($pos = 1)">
            <xsl:choose>
            <xsl:when test="name() =
preceding-sibling::*[$OrderName]">
	<table>
    <tr><xsl:value-of select="name()"/></tr>
	<tr>
<td><xsl:value-of
select="string(preceding-sibling::*[$OrderName])"
/></td>
	</tr>
   <tr>
<xsl:value-of select="string($OrderName)"/>
</tr>
</table>
<xsl:text> </xsl:text>
	</xsl:when>
	<xsl:otherwise>
			<table>
	       		  	<tr>
	       		  	<xsl:value-of
select="string($OrderName)"/>
	       		  	</tr>
			</table>
	</xsl:otherwise>
</xsl:choose>
					</xsl:when>
			         </xsl:choose>
		      </p>
	    </xsl:for-each>
</xsl:template>



Appreciate your time.

Thanks
Nischal


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

 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.