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 June 8th, 2006, 03:11 AM
Registered User
 
Join Date: Jun 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Very high XSL Problem

Hello everyone,
i have got a big problem, which I haven't resolved yet.

I have to transform from one xml file to another, but it seems that xsl(t) is not able to resolve my transformations.
i have got following xml-source (explanatory):

<table name="table1" schema="schema1"/>
<table name="table2" schema="schema2"/>
<table name="table3" schema="schema1"/>
<table name="table4" schema="schema1"/>


the output should be:

<Schema name="schema1" tables="table1 table3 table4"/>
<Schema name="schema2" tables="table2"/>

How to transform this kind of structure
1. without depending of any xslt-processor
2. and do the step in one transformation!
(not two xsl transformation files)

cheers for any response.
I am desparate with that problem..



 
Old June 8th, 2006, 08:30 AM
Registered User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can solve this using the xslt2 "for-each-group" element (hopefully your processor can handle that):
<xsl:template match="/tables">
 <Database>
  <xsl:for-each-group select="table" group-by="@schema">
   <schema>
    <xsl:attribute name="name">
      <xsl:value-of select="current-grouping-key()"/>
    </xsl:attribute>
    <xsl:attribute name="tables">
     <xsl:value-of select="current-group()/@name"/>
    </xsl:attribute>
   </schema>
  </xsl:for-each-group>
 </Database>
</xsl:template>

Thanks,
Francine.

 
Old June 8th, 2006, 04:51 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This is a simple grouping problem.

Simple grouping problems can be solved in XSLT 2.0 using the xsl:for-each-group construct, or in 1.0 using the Muenchian grouping technique described at http://www.jenitennison.com/xslt/grouping



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
help me to make high light menu at VS 6. C++ asdfci Visual C++ 0 July 24th, 2007 12:24 PM
High Cpu usage Cruz_240sx Classic ASP Components 2 March 20th, 2007 06:42 AM
High Low Card Game vtvb VB.NET 2002/2003 Basics 1 September 23rd, 2005 01:21 PM
Page Faults High niallhannon SQL Server 2000 1 February 25th, 2004 05:45 PM





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