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 December 4th, 2007, 07:03 PM
Authorized User
 
Join Date: Dec 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Urgent:XSLT element value selection and condition

In the example below I have pasted my source and resultant xml.Basically i want to gather similar types of "mapping" under one tag.
I plan to first traverse the xml to gather unique mappings and then for each unique mapping i want to construct the row tag.
URGENT:How do i do this in XSL.Pls help.Urgent.

Source
--------
<tableData>
        <strData>
            <mapping>Bucket</mapping>
            <alignment>center</alignment>
            <stringValue>008/stringValue>
        </strData>

        <strData>
            <mapping>Other</mapping>
            <alignment>left</alignment>
            <stringValue>BBB</stringValue>
        </strData>

        <strData>
            <mapping>Bucket</mapping>
            <alignment>right</alignment>
            <stringValue>005/stringValue>
        </strData>

        <strData>
            <mapping>Other</mapping>
            <alignment>left</alignment>
            <stringValue>CCC</stringValue>
        </strData>
</tableData>

Resultant
----------
<tableData>
        <mappingtype>Bucket</mappingtype>
        <row>
            <stringValue>008</stringValue>
            <stringValue>005</stringValue>
        </row>

        <mappingtype>Other</mappingtype>
        <row>
            <stringValue>BBB</stringValue>
            <stringValue>CCC</stringValue>
        </row>

</tableData>



 
Old December 4th, 2007, 07:57 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 standard grouping problem. In XSLT 2.0, use the xsl:for-each-group instruction. In 1.0, use a technique such as Muenchian grouping described at http://www.jenitennison.com/xslt/grouping

Generally, it's a bad idea to say three times that your question is urgent. Many people don't reply to such posts, because it often means that the question has been posted without taking the time to research available information first, and it also often means that people come back instantly with supplementary questions rather than taking the time to study and digest the answer.

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
XSLT - fetching element value without getting the samridhis XSLT 4 August 11th, 2008 03:30 AM
XSLT and the if condition thisby XSLT 7 April 3rd, 2008 06:02 PM
Element value type in XSLT 1.0 NEO1976 XSLT 9 February 13th, 2007 11:11 AM
Please help me to create XSLT condition using C# Nick2006 C# 8 July 12th, 2006 06:48 PM
IIS Semaphore Condition[Urgent Help Required] farhan_iac General .NET 4 August 12th, 2004 10:00 AM





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