Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

a simple xml-xslt transformation

Posted on 2011-02-13
3
Medium Priority
?
398 Views
Last Modified: 2012-05-11
Sorry for the lameness of the question, but I need to figure this out fast.

I have this example xml:
<event>
        <Org_Name><![CDATA[Community Music Center]]>
        </Org_Name>
        <Venue_Name><![CDATA[Community Music Center]]>
        </Venue_Name>
        <Venue_address><![CDATA[544 Capp]]>
        </Venue_address>
        <Event_Phone><![CDATA[647-6015]]>
        </Event_Phone>
        <Org_Web><![CDATA[HTTP://www.sfcmc.org]]>
        </Org_Web>
        <Date_String><![CDATA[Mar 25]]>
        </Date_String>
        <Time_String><![CDATA[Sun at 4 pm]]>
        </Time_String>
        <Event_Name><![CDATA[Andrew Meyerson and Friends ]]>
        </Event_Name>
        <Event_Description><![CDATA[Andrew Meyerson and guest artists perform contemporary musical selections. ]]>
        </Event_Description>
        <Ticket_String><![CDATA[$10; $5 seniors & students]]>
        </Ticket_String>
    </event>
    <event>
        <Org_Name><![CDATA[Stanford Lively Arts]]>
        </Org_Name>
        <Venue_Name><![CDATA[Community School of Music and Arts]]>
        </Venue_Name>
        <Venue_address><![CDATA[230 San Antonio Circle]]>
        </Venue_address>
        <Event_Phone><![CDATA[650/725-ARTS]]>
        </Event_Phone>
        <Org_Web><![CDATA[HTTP://livelyarts.stanford.edu]]>
        </Org_Web>
        <Date_String><![CDATA[Mar 3]]>
        </Date_String>
        <Time_String><![CDATA[Thu at 6 pm]]>
        </Time_String>
        <Event_Name><![CDATA[Trio Voce]]>
        </Event_Name>
        <Event_Description><![CDATA[Free and engaging one-hour program of performance and conversation.]]>
        </Event_Description>
        <Ticket_String><![CDATA[Free]]>
        </Ticket_String>
    </event>
    <event>
        <Org_Name><![CDATA[Stanford Lively Arts]]>
        </Org_Name>
        <Venue_Name><![CDATA[Community School of Music and Arts]]>
        </Venue_Name>
        <Venue_address><![CDATA[230 San Antonio Circle]]>
        </Venue_address>
        <Event_Phone><![CDATA[650/725-ARTS]]>
        </Event_Phone>
        <Org_Web><![CDATA[HTTP://livelyarts.stanford.edu]]>
        </Org_Web>
        <Date_String><![CDATA[Apr 12]]>
        </Date_String>
        <Time_String><![CDATA[Tue at 6 pm]]>
        </Time_String>
        <Event_Name><![CDATA[Loren Schoenberg & Gunn High School Jazz Band]]>
        </Event_Name>
        <Event_Description><![CDATA[Free “Informance” at the Community School for Music and Arts featuring the music of jazz legend Charles Mingus in an engaging one-hour program of performance and conversation in Tateuchi Hall at the CSMA in Mountain View.]]>
        </Event_Description>
        <Ticket_String><![CDATA[Free]]>
        </Ticket_String>
    </event>

You will notice that of the three event nodes, two are from one Org_Name. How can I apply an xslt transform to output two event nodes, one of which is comprised of the two stanford event details.

Appreciate any help I can get. I have no time to learn xslt from the ground up.

lrlarson
NYC
0
Comment
Question by:lrlarson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 34886030
The way you put it sounds like "can someone write me some code"
That is not what EE is meant for. For that you usually hire a consultant.

The task is not too hard, but requires some understanding of Muenchian grouping
http://www.jenitennison.com/xslt/grouping/muenchian.xml

Below is the XSLT, I hope you are willing to learn enough XSLT for possible changes you require
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
    <xsl:output indent="yes" cdata-section-elements="Org_Name Venue_Name Venue_address Event_Phone Org_Web Date_String Time_String Event_Name Event_Description Ticket_String"/>
    <xsl:strip-space elements="*"/>
    <xsl:key name="ev" match="event" use="Org_Name"/>
    <xsl:template match="/">
        <events>
            <xsl:for-each select="//event[generate-id() = generate-id(key('ev', Org_Name)[1])]">
               <organisation>
                   <xsl:copy-of select="Org_Name | Venue_Name | Venue_address | Event_Phone | Org_Web"/>
                   <xsl:for-each select="key('ev', Org_Name)">
                       <event>
                           <xsl:copy-of select="Date_String | Time_String | Event_Name | Event_Description | Ticket_String"/>
                       </event>
                   </xsl:for-each>
               </organisation>
            </xsl:for-each>
        </events>
    </xsl:template>

</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:lrlarson
ID: 34887829
Thank you. I didn't mean my request to sound the way it evidently did, I just needed a pointer since I did not haver time to start from scratch.

Thank you for taking the time -- this is very helpful.
lrlarson
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 34887868
welcome
0

Featured Post

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question