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

RE: NewBie:pls Help!

  • From: René de Vries <RdVries@P...>
  • To: xml-dev@l...
  • Date: Mon, 27 Aug 2001 10:28:50 +0200

priyanka asija
Hi Priyanka,

First I advise you to become a member of the "XSL-List - the Open Forum on
XSL" at www.mulberrytech.com. In most cases you'll get an answer to your
question within an hour.

Furthermore I advise you to read a good book about XSL(T), for example XSLT
2nd Edition, Programmer's Reference, by Michael Kay, ISBN: 1-861005-06-7.
Your basic programming technique is not XSL-like. You are programming
sequentially while you should think in templates!

The first line of your XSL should be:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
The WD-xsl is a non-standard Microsoft Working Draft.

It could be that you have to upgrade your browser. (your XSL works fine with
me). IE comes standard with MSXML.DLL, the first XML-parser which cannot
transform well. You can upgrade to MSXML3.DLL via the Microsift site.
Maybe this or the WD-xsl-line is your major-problem.

I rewrote your XSL (which works OK) in XSL-style, to give you an idea what I
mean:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="Parent">
		<html>
			<body>

				<table border="1">
					<tr>
						<td>Child1</td>
						<td>Child2</td>
						<td>Child3</td>
						<td>Child4</td>
						<td>Child5</td>
						<td>Child6</td>
					</tr>

					<xsl:apply-templates select="Child"/>

					<th>
						<h1>Children</h1>
					</th>

					<tr>
						<td>Sibling1</td>
						<td>Sibling2</td>
						<td>Sibling3</td>
						<td>Sibling4</td>
						<td>Sibling5</td>
					</tr>

					<xsl:apply-templates select="Child/Children"/>

				</table>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="Child">
		<tr>
			<td><xsl:value-of select="Child1"/></td>
			<td><xsl:value-of select="Child2"/></td>
			<td><xsl:value-of select="Child3"/></td>
			<td><xsl:value-of select="Child4"/></td>
			<td><xsl:value-of select="Child5"/></td>
			<td><xsl:value-of select="Child6"/></td>
		</tr>

	</xsl:template>

	<xsl:template match="Children">
		<xsl:apply-templates select="Siblings"/>
	</xsl:template>

	<xsl:template match="Siblings">
		<tr>
			<td><xsl:value-of select="Sibling1"/></td>
			<td><xsl:value-of select="Sibling2"/></td>
			<td><xsl:value-of select="Sibling3"/></td>
			<td><a href="{Sibling4}"><xsl:value-of
select="Sibling4"/></a></td> <!-- my problem spot..-->
			<td><xsl:value-of select="Sibling5"/></td>
		</tr>

	</xsl:template>

</xsl:stylesheet>

Greetings René
   {@   @}
      ^
     \_/

"You don't need eyes to see, you need vision!"

-----Oorspronkelijk bericht-----
Van: Priyanka Asija [mailto:priyanka@n...]
Verzonden: maandag 27 augustus 2001 9:09
Aan: xml-dev@l...
Onderwerp: NewBie:pls Help!



Dear XMLers,

Please guide me...

I have an xml file

<Parent>
<Child>
    <Child1>data</Child1>
    <Child2>data</Child2>
    <Child3>data</Child3>
    <Child4>data</Child4>
    <Child5>data</Child5>
    <Child6>data</Child6>

    <Children>
	<Siblings>
	    <Sibling1>Data of Sibling1</Sibling1>
	    <Sibling2>Data of Sibling2</Sibling2>
	    <Sibling3>Data of Sibling3</Sibling3>
	    <Sibling4>Data of Sibling4 </Sibling4>
	    <Sibling5>Data of Sibling5</Sibling5>
	</Siblings>
    </Children>

</Child>
</Parent>


and the corresponsing XSL,

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
  <html>
  <body>

  <table border="1">
  	<tr>
    		<td>Child1</td>
    		<td>Child2</td>
    		<td>Child3</td>
    		<td>Child4</td>
    		<td>Child5</td>
    		<td>Child6</td>
    	</tr>

    	<xsl:for-each select="Parent/Child" >
    	<tr>
    		<td><xsl:value-of select="Child1"/></td>
    		<td><xsl:value-of select="Child2"/></td>
    		<td><xsl:value-of select="Child3"/></td>
    		<td><xsl:value-of select="Child4"/></td>
    		<td><xsl:value-of select="Child5"/></td>
   		<td><xsl:value-of select="Child6"/></td>
    	</tr>
    	</xsl:for-each>


	<th>
		<h1>Children</h1>
	</th>

    	<tr>
		<td>Sibling1</td>
		<td>Sibling2</td>
		<td>Sibling3</td>
		<td>Sibling4</td>
		<td>Sibling5</td>
    	</tr>

 	<xsl:for-each select="Parent/Child/Children/Siblings">
 	      <tr>
	   	 <td><xsl:value-of select="Sibling1"/></td>
	   	 <td><xsl:value-of select="Sibling2"/></td>
	   	 <td><xsl:value-of select="Sibling3"/></td>

	   	 <td><a href="{Sibling4}"><xsl:value-of
select="Sibling4"/></a></td> <!-- my problem spot..-->

	   	 <td><xsl:value-of select="Sibling5"/></td>
	      </tr>
	</xsl:for-each>

   </table>
   </body>
   </html>
</xsl:template>
</xsl:stylesheet>


Problem:

I want the value of the Sibling4 to be placed in the href value, and i
am doing it through <a href="{Sibling4}"> but the value is not getting
substituted, is there anything wrong with what i am doing?

Please guide me..

I am in desperate need........

Thankyou in advance
XML Learner


-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this elist use the subscription
manager: <http://lists.xml.org/ob/adm.pl>


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.