Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] XSL distinct group by date

From: "Mindy McCutchan" <karma@-------------->
To:
Date: 5/1/2005 7:13:00 PM
Peter,
My apologies for the late reply. I had another project pop up in between
this one. Thank you for the suggestion. That solved my problem. However,
I've encountered another issue. 

I've been using this as a guide:
http://sources.redhat.com/ml/xsl-list/2000-07/msg00458.html

I've slightly altered that XML set to fit the structure of my XML and it
doesn't do as I would have expected. I'm hoping someone can explain why to
me.

Altered XML:

<company>
	<projects>
		<project>
			<name>Customer 1</name>
		</project>
		<project>
			<name>Customer 2</name>
		</project>
		<project>
			<name>Customer 2</name>
		</project>
	</projects>
	<papers>
		<paper>
			<title>A Paper Title</title>
		</paper>
	</papers>
</company>

Now if I use the XSLT in the above link
(http://sources.redhat.com/ml/xsl-list/2000-07/msg00458.html), it does
return the distinct customer name values, but it also writes out the value
of the nodes outside the /projects level, yielding: Customer 1Customer 2 A
Paper Title

Any explanation of this behavior would be very helpful.

Thank you and again, my apologies for the delay in response.

Mindy

> >-----Original Message-----
> >Date: Mon, 25 Apr 2005 13:23:55 -0400
> >To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> >From: "Jacoby, Peter R." <PJACOBY@xxxxxxxxxxxx>
> >Subject: RE: [xsl] XSL distinct group by date
> >Message-ID: 
> ><3CFEFF6C55FB5C42A6E68E9521D5C436DBC219@xxxxxxxxxxxxxxxxxxxx>
> >
> >Mindy,
> >
> >If you want to group your elements by only the year portion 
> >of the date, =
> >then
> >you need to change your xsl:key use attribute to only look 
> >at the year.
> >Something like:
> >
> ><xsl:key name=3D"documents-by-date" match=3D"newsitem" =
> >use=3D"substring(date,
> >string-length(date)-3, 4)" />
> >
> >Then you would call it with the same=20
> >key('document-by-date', '2004')=20
> >
> >or in your code
> >key('documents-by-date', substring(date, string-length(date)-3, 4))
> >
> >One other piece that you may want to try is grouping more than just =
> >newsitem
> >elements together (I couldn't tell from your original post 
> >if this is =
> >what you
> >are looking for or not).  You can use the union operator | 
> >to match on =
> >more than
> >one named element.  Something like:
> ><xsl:key name=3D"documents-by-date" match=3D"newsitem  | 
> >whitepapers |
> >pressreleases" use=3D"substring(date, string-length(date)-3, 4)" />
> >
> >As you said, you could make it (slightly) simpler by storing 
> >the year in =
> >a
> >separate element (or attribute), but it's not necessary to get the =
> >desired
> >functionality.
> >
> >Hope this helps.
> >
> >-Peter


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent