Given an XML structured as

dogs
dog @id
name
family
father
mother

Where the father and the mother are identified by @id, and are of course peer nodes. I need to print out the name instead of the id in XSLT inside a for-each loop.

What is the Best Practice way to do this?

Thank you!

My apologies, the editor stripped my indentation...

More specifically, here is the XML, and notice that the <mate> and <offspring> are identified by an id (string) that correlates to the @id of another <monkey>:

<monkeys>
	<monkey id="m001">
		<name>John</name>
		<age>5</age>
		<n_bananas>6</n_bananas>
		<isHungry>true</isHungry>
		<weight>10</weight>
		<isKilos>true</isKilos>
		<isFemale>false</isFemale>
		<family>
			<mate>m003</mate>
			<offspring>
				<child_id>m005</child_id>
			</offspring>
		</family>
	</monkey>

Now, here is the XSLT, and what I want to do is replace the <mate> string (which is the @id of another <monkey>) to the <name> associated with it:

<!--  MATE COLUMN </!--> 
					
					<xsl:variable name="mateid">
						<xsl:value-of select="*/mate"/>
					</xsl:variable>					
					
					<xsl:choose>
						<xsl:when test="*/mate">
							<td><xsl:value-of select="$mateid"/></td>		
						</xsl:when>
						<xsl:otherwise>
							<td>N/A</td>
						</xsl:otherwise>
					</xsl:choose>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.