[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Raj,
If you want to generate a table with a single column then you do not need access to siblings, you get that by processing the all the nodes in document order with your existing templates. You just need to replace
with
<xsl:apply-templates/>
If you need a to generate a TR for each FRUIT then you need access to following siblings like below:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="FRUIT">
<HTML>
<HEAD><TITLE>XSL TEST</TITLE></HEAD>
<BODY>
<TABLE>
<xsl:apply-templates select="IDENTIFICATION"/>
</TABLE>
</BODY>
</HTML>
</xsl:template>
You process from the FRUIT template only the IDENTIFICATION elements. In the IDENTIFICATION template output the TR and the first column then process the following APPEARANCE. The template matching APPEARANCE output a column and will process the following STORAGE that will just output the last column.
Of course if you have control over your input is is better to change it as suggested in other posts.
rajasekhar v wrote:
Re: [xsl] Sibling access in XSL !
Subject: Re: [xsl] Sibling access in XSL ! From: George Cristian Bina <george@xxxxxxx> Date: Fri, 24 Sep 2004 10:39:28 +0300 |
Raj,
If you want to generate a table with a single column then you do not need access to siblings, you get that by processing the all the nodes in document order with your existing templates. You just need to replace
> <xsl:apply-templates select="IDENTIFICATION"/> > <xsl:apply-templates select="APPEARANCE"/> > <xsl:apply-templates select="STORAGE"/>
with
<xsl:apply-templates/>
If you need a to generate a TR for each FRUIT then you need access to following siblings like below:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="FRUIT">
<HTML>
<HEAD><TITLE>XSL TEST</TITLE></HEAD>
<BODY>
<TABLE>
<xsl:apply-templates select="IDENTIFICATION"/>
</TABLE>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="IDENTIFICATION"> <TR> <TD><xsl:value-of select="NAME"/></TD> <xsl:apply-templates select="following-sibling::APPEARANCE[1]"/> </TR> </xsl:template>
<xsl:template match="APPEARANCE"> <TD><xsl:value-of select="COLOR"/></TD> <xsl:apply-templates select="following-sibling::STORAGE[1]"/> </xsl:template>
<xsl:template match="STORAGE"> <TD><xsl:value-of select="TEMP"/></TD> </xsl:template> </xsl:stylesheet>
You process from the FRUIT template only the IDENTIFICATION elements. In the IDENTIFICATION template output the TR and the first column then process the following APPEARANCE. The template matching APPEARANCE output a column and will process the following STORAGE that will just output the last column.
Of course if you have control over your input is is better to change it as suggested in other posts.
Hope that helps, George ----------------------------------------------- George Cristian Bina <oXygen/> XML Editor & XSLT Editor/Debugger http://www.oxygenxml.com
rajasekhar v wrote:
Hi,
I have got a simple XML like this which has some information about fruits
----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone ="yes"?> <FRUIT> <IDENTIFICATION> <NAME>APPLE</NAME> </IDENTIFICATION>
<APPEARANCE> <COLOR>RED</COLOR> </APPEARANCE>
<STORAGE> <TEMP>STORE APPLES UNDER 20 DEGREE</TEMP> </STORAGE>
<IDENTIFICATION> <NAME>GRAPE</NAME> </IDENTIFICATION>
<APPEARANCE> <COLOR>BLACK</COLOR> </APPEARANCE>
<STORAGE> <TEMP>STORE GRAPES UNDER 30 DEGREE</TEMP> </STORAGE>
</FRUIT>
----------------------------------------------------------------------------------------------------
When i ran the above XML with the following XSL and Xalan parser,
----------------------------------------------------------------------------------------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="FRUIT">
<HTML>
<HEAD><TITLE>XSL TEST</TITLE></HEAD>
<BODY>
<TABLE>
<xsl:apply-templates select="IDENTIFICATION"/>
<xsl:apply-templates select="APPEARANCE"/>
<xsl:apply-templates select="STORAGE"/>
</TABLE>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="IDENTIFICATION"> <TR><TD><xsl:value-of select="NAME"/></TD></TR> </xsl:template>
<xsl:template match="APPEARANCE"> <TR><TD><xsl:value-of select="COLOR"/></TD></TR> </xsl:template>
<xsl:template match="STORAGE">
<TR><TD><xsl:value-of select="TEMP"/></TD></TR>
</xsl:template>
</xsl:stylesheet>
----------------------------------------------------------------------------------------------------
I got the output as :
----------------------------------------------------------------------------------------------------
APPLE
GRAPE
RED
BLACK
STORE APPLES UNDER 20 DEGREE
STORE GRAPES UNDER 30 DEGREE
----------------------------------------------------------------------------------------------------
But i need the output as
----------------------------------------------------------------------------------------------------
APPLE RED STORE APPLES UNDER 20 DEGREE
GRAPE
BLACK
STORE GRAPES UNDER 30 DEGREE
----------------------------------------------------------------------------------------------------
i.e the details of apples appearing first followed by grape.
Please let me the know the ways of doing this - to identify the following node and process accordingly.
Regards, Raj
_________________________________________________________________
Movies, music, celeb news. Stay in the loop. http://www.msn.co.in/cinema/ With MSN Entertainment!
--+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Sibling access in XSL !, Michael Kay | Thread | [xsl] Namespaces, params and Xalan, Fraser Crichton |
RE: [xsl] Using a pre-processor for, Michael Kay | Date | Re: [xsl] [text nodes] Unmatching t, Chizzolini Stefano |
Month |
Keywords