Jump to content

XSLT Grouping of Elements


mzimmerman

Recommended Posts

I'm thrilled to have found a forum where I can post a question of this nature. Thank You....I've spent days buried in various XSLT reference books, but still am unable to find a way to accomplishwhat I am trying to do. (And its making me feel REAL STUPID)I simply need to take XML which is output from a Database query and reformat for use by a Metric tool.I've been through some of the painful Muenchian method documentation, and am still struggling.I simply need to go from:<ROW> <NAME>ABC</NAME> <NUMBER>123</NUMBER></ROW><ROW> <NAME>XYZ</NAME> <NUMBER>789</NUMBER?</ROW>To:<ROW> <TITLE>ABC</TITLE> <TITLE>XYZ</TITLE></ROW><ROW> <VALUE>123</VALUE> <VALUE>789</VALUE>I believe I will have to use keys, but still continue to get values combined under <Row> parents.Any assistance gratefully accepted.Highest Regards,

Link to comment
Share on other sites

try this.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >	<xsl:output method="xml"/>	<xsl:template match="/">		<ROW>			<xsl:for-each select="//NAME">				<TITLE><xsl:value-of select="text()"/></TITLE>			</xsl:for-each>		</ROW>		<ROW>			<xsl:for-each select="//NUMBER">				<VALUE><xsl:value-of select="text()"/></VALUE>			</xsl:for-each>		</ROW>	</xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...