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

Re: How do I change a XSL style sheet to group data t

Subject: Re: How do I change a XSL style sheet to group data together under one heading
From: "kieters c" <kieters@xxxxxxxxxxx>
Date: Mon, 21 May 2007 14:22:31 +0000
Re:  How do I change a XSL style sheet to group data  t
I have tried the following and the error mesage for each.

<!-- date-time must become an attribute -->
<xsl:apply-templates select="sample_date_time, cp_name, imis_cp_ext, dischg_sample_cd, sample_comment" /> ####
<xsl:apply-templates select="key('sample', concat(sample_date_time, cp_name, imis_cp_ext, dischg_sample_cd, sample_comment))" />


and
<xsl:apply-templates select="*[not(self::sample_date_time, cp_name, imis_cp_ext, dischg_sample_cd, sample_comment)]" />


Line 16, character 38   (I assume it is line   ###)
Stylesheet error:  Invalid XPath Expression
Select

<!-- date-time must become an attribute -->
<xsl:apply-templates select="sample_date_time" />
<xsl:apply-templates select="key('sample', concat(sample_date_time, cp_name, imis_cp_ext, dischg_sample_cd, sample_comment))" />


And
<xsl:apply-templates select="*[not(self::sample_date_time, cp_name, imis_cp_ext, dischg_sample_cd, sample_comment)]


error:

Line 24 character 34
Error in XPath Expression,
Error in XPath Expression,

Finally I tried the same as above but

<xsl:apply-templates select="*[not(self::concat(sample_date_time, cp_name, imis_cp_ext, dischg_sample_cd, sample_comment))]" />

Error
Line 24 character 34
Stylesheet error: Invalid XPath Expression
Select

I unfortunately do not have any say in the format of the final result as it is laid down by some other authority.

Thanks.

Hennie

From: Abel Braaksma <abel.online@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: How do I change a XSL style sheet to group data together under one heading
Date: Mon, 21 May 2007 14:13:18 +0200


kieters c wrote:

The resuslt I need to get is :


<sample sample_date_time="20061001" cp_name="Neutr. Sump WTPE" imis_cp_ext="2300" dischg_sample_cd=" " sample_comment=" ">
<result rpttime_name="Daily" sis_imis_code="RSP" parm_name="Residue, particulate" >
<result rpttime_name="Daily" sis_imis_code="FTFLOW" parm_name="Flow" />
</sample>


In other words sample_date_time, cp_name, dischg_sample_cd, ect grouped together and the rest grouped with result.

Which to me seems equal to mine, except that yours is with a bit more data. You can just concatenate more items together if you want (in my example it is only sample_date_time and cp_name). And if you need them as attributes too (like you show above), you can do so by changing the apply-templates for the attributes, plus changing the not(self::..... etc) expression, because these elements that you want transformed in attributes appear on the same level in the hierarchy and as such you'll have to specify them specifically and ignore them later.


It may be easier to create an extra key with these elements that you want transformed into attributes. You can leave the @use attribute empty. Something like this should work, I think:

<xsl:key name="turn-into-attr" match="sample_date_time | cp_name | etc etc" use=" '' " />

but that's just a matter of taste (note that you'll have to change some apply-templates as well to use this new key). You can also just copy your logic.

Cheers,
-- Abel Braaksma


_________________________________________________________________
Share folders without harming wildlife! http://www.communicationevolved.com/en-za/


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.