removing/combining doubles in xml

L

lievemario

Hey,

I have generated following xml file (using perl,dbi),

Now I would like to display this with the help of xsl

such that I have the following result:

A B (XXXX) (YYYY)

Can someone help me with that?

Thanks

Here is the xml file

<List_personnel>

<select>

<Personnel_member>

<person_id>224</person_id>

<name>A</name>

<first_name>B</first_name>

<team_code>XXXX</team_code>

</Personnel_member>

<Personnel_member>

<person_id>224</person_id>

<name>A</name>

<first_name>B</first_name>

<team_code>YYYY</team_code>

</Personnel_member>

</select>

</List_personnel>
 
J

Joris Gillis

I have generated following xml file (using perl,dbi),
Now I would like to display this with the help of xsl

such that I have the following result:

A B (XXXX) (YYYY)

Can someone help me with that?

Hi,
In XSLT 1.0, there is no standard way to do that task, but you can use e.g. generate-id() in combination with key() , to obtain a result. Another way is to use extension functions.
This is a possible solution:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:eek:utput method="text"/>

<xsl:key name="p_id" match="Personnel_member" use="person_id"/>

<xsl:template match="select">
<xsl:for-each select="Personnel_member[ generate-id(.) = generate-id(key('p_id',person_id))]">
<xsl:apply-templates select="name"/>
<xsl:apply-templates select="first_name"/>
<xsl:apply-templates select="../Personnel_member[person_id=current()/person_id]/team_code"/>
</xsl:for-each>
</xsl:template>

<xsl:template match="team_code">
(<xsl:value-of select="."/>)
</xsl:template>

</xsl:stylesheet>



regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top