Subject: Re: [xsl] How do I change a XSL style sheet to group data together under one heading From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Thu, 17 May 2007 20:08:01 +0200 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- the key determines (here) what to group by --> <xsl:key name="sample" match="sample" use="sample_date_time" />
<xsl:template match="/"> <submission imis_company_code="0001843309" ws_name="LENNOX"> <xsl:apply-templates /> </submission> </xsl:template>
<!-- match the sample's that are grouped --> <xsl:template match="sample"> <result> <xsl:apply-templates select="*[not(self::sample_date_time)]" /> </result> </xsl:template>
<!-- any direct child of 'sample' must be turned into an attribute --> <xsl:template match="sample/*"> <xsl:attribute name="{name()}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template>
<submission imis_company_code="0001843309" ws_name="LENNOX"> <sample sample_date_time="20040801"> <result rpttime_name="DAILY" sis_imis_code="FTFLOW"/> <result rpttime_name="DAILY" sis_imis_code="PH"/> </sample> </submission>
HTH!, Cheers, -- Abel Braaksma
Good day,
I am sorry it once again happened. I will delete some of the data in between as it I would be able to correct it afterwards. I have removed most data and background clutter and hope it is correct now.
I attach an abbreviated version of the present XML file and what I hope to achieve. The flat file and an abbreviated style sheet.
Once again thank you for valuable time.
Hennie
From <?xml version="1.0" ?> <sample sample_date_time="20040801" > <result rpttime_name="DAILY" sis_imis_code="FTFLOW/> </sample> <sample sample_date_time="20040801" <result rpttime_name="DAILY" sis_imis_code="PH" /> </sample>
To <?xml version="1.0" ?> <sample sample_date_time="20040801" > <result rpttime_name="DAILY" sis_imis_code="FTFLOW/> <result rpttime_name="DAILY" sis_imis_code="PH" /> </sample>
Flat file
<dataroot> <sample> <sample_date_time>20040801</sample_date_time> <rpttime_name>DAILY</rpttime_name> <sis_imis_code>FTFLOW</sis_imis_code> </sample> <sample> <sample_date_time>20040801</sample_date_time> <rpttime_name>DAILY</rpttime_name> <sis_imis_code>PH</sis_imis_code> <sample> </dataroot>
Style sheet
<?xml version="1.0" encoding="iso-8859-1"?><!--sample.xsl--> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <submission imis_company_code="0001843309" ws_name="LENNOX"> <xsl:apply-templates/> </submission> </xsl:template>
<xsl:template match="sample"> <sample sample_date_time="sample_date_time" <result rpttime_name="rpttime_name" sis_imis_code="sis_imis_code" </sample> </xsl:template> </xsl:stylesheet>
_________________________________________________________________
Message offline contacts without any fire risk! http://www.communicationevolved.com/en-za/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How do I change a XSL sty, kieters c | Thread | Re: [xsl] How do I change a XSL sty, kieters c |
Re: [xsl] Tutorial for collection(), Florent Georges | Date | Re: [xsl] How do I change a XSL sty, kieters c |
Month |