Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 2nd, 2010, 03:17 PM
Registered User
 
Join Date: Mar 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried but not much success: I did look through the XPATH tutorial.

I need "yo" and "yo2" element2 output as well...i keep getting 6 groups with values from misc1 tags only is first 3 groups, then misc2 elements in the next 3 groups.

Input:

<tag>
<misc1>
<addedlevel1>
<yo>
<matchfield>A</matchfield>
<another>1</another>
</yo>
</addedlevel1>
</misc1>
<misc1>
<addedlevel1>
<yo>
<matchfield>B</matchfield>
<another>5</another>
</yo>
</addedlevel1>
</misc1>
<misc2>
<addedlevel2>
<yo2>
<matchfield>A</matchfield>
<anotherone>2</anotherone>
</yo2>
</addedlevel2>
</misc2>
<misc2>
<addedlevel2>
<yo2>
<matchfield>B</matchfield>
<anotherone>9</anotherone>
</yo2>
</addedlevel2>
</misc2>
</tag>


output:

Thoughts?
 
Old April 2nd, 2010, 03:20 PM
Registered User
 
Join Date: Mar 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind...i got it i think

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>

<xsl:key name="k1" match="tag/*" use="*/*/matchfield"/>

<xsl:template match="tag">
<xsl:copy>
<xsl:for-each select="*[generate-id() = generate-id(key('k1', */*/matchfield)[1])]">
<group>
<xsl:copy-of select="key('k1', */*/matchfield)"/>
</group>
</xsl:for-each>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>
 
Old April 2nd, 2010, 03:38 PM
Registered User
 
Join Date: Mar 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey just wanted to say thanks again. I have what i need now. To complicate things is that i had a single whitespace that wouldn't let grouping occur for days now.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to group xsl elements in xslt.10 suji XSLT 1 February 29th, 2008 03:44 AM
how t do comparision of elements in xsl suji XSLT 2 February 28th, 2008 12:27 PM
Adding elements from an XML to XSL. AjayLuthria XSLT 1 May 1st, 2007 12:12 PM
Dynamically Finding Elements in XSL tclancy XSLT 2 March 1st, 2006 03:25 PM
Reordering Using XSL zenmaster XSLT 2 December 7th, 2005 08:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.