XSLT1.0: remove duplicates combined with an xsl:key
Posted
by
Jannibal
on Stack Overflow
See other posts from Stack Overflow
or by Jannibal
Published on 2013-11-07T15:51:51Z
Indexed on
2013/11/07
15:52 UTC
Read the original article
Hit count: 243
I have the following piece of XML:
<research>
<research.record>
<research.record_number>1</research.record_number>
<research.type>
<value lang="en-US">some research type</value>
</research.type>
<research.type>
<value lang="en-US">some other type of research</value>
</research.type>
<project.record>
<priref>101</priref>
<project.type>
<value lang="en-US">some type of project</value>
</project.type>
</project.record>
</research.record>
</research>
<research>
<research.record>
<research.record_number>2</research.record_number>
<research.type>
<value lang="en-US">some other type of research</value>
</research.type>
<research.type>
<value lang="en-US">a third type of research</value>
</research.type>
<project.record>
<priref>101</priref>
<project.type>
<value lang="en-US">some type of project</value>
</project.type>
</project.record>
</research.record>
</research>
<research>
<research.record>
<research.record_number>3</research.record_number>
<research.type>
<value lang="en-US">some other type of research</value>
</research.type>
<research.type>
<value lang="en-US">a fourth type</value>
</research.type>
<project.record>
<priref>201</priref>
<project.type>
<value lang="en-US">some other type of project</value>
</project.type>
</project.record>
</research.record>
</research>
<research>
... etc ...
With XSLT 1.0 I transform this XML into a list of unique project records by using xsl:key.
So far, so good...
The problem is: I also want to show unique research types for each unique project record.
My wanted output would be:
project.record 101: some research type, some other type of research, a third type of research
project.record 201: some other type of research, a fourth type
Hope someone can help me out with the right XSLT/XPATH. (Can only use XSLT1.0)
© Stack Overflow or respective owner