Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4271450
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:26:38+00:00 2026-05-21T07:26:38+00:00

I apologize for not knowing xsl very well, but i have an xml document

  • 0

I apologize for not knowing xsl very well, but i have an xml document that I would like to transform and I’ve not been able to find an example that works for me. I would like to merge the locations into a single element. I have the following document:

<?xml version="1.0" encoding="UTF-8"?><tfs_events> 
<title>Referees Events</title> 
<event> 
    <id>256</id> 
    <name>SB-V,SB-JV vs McKinley HS</name> 
    <time_start>2011-04-12 17:00:00</time_start> 
    <time_end>2011-04-12 19:00:00</time_end> 
    <status>Active</status> 
    <locations>     
        <id>116</id> 
        <name>Lake Athletic Complex</name> 
    </locations> 
</event> 
<event> 
    <id>257</id> 
    <name>SB-V,SB-JV vs Jackson HS</name> 
    <time_start>2011-04-14 17:00:00</time_start> 
    <time_end>2011-04-14 19:00:00</time_end>
    <status>Active</status> 
    <locations> 
        <id>116</id> 
        <name>Athletic Complex</name> 
    </locations> 
    <locations> 
        <id>6</id> 
        <name>HS Baseball Field</name> 
    </locations>
</event>

I am trying to make it like this:

<?xml version="1.0" encoding="UTF-8"?><tfs_events> 
<title>Referees Events</title> 
<event> 
    <id>256</id> 
    <name>SB-V,SB-JV vs McKinley HS</name> 
    <time_start>2011-04-12 17:00:00</time_start> 
    <time_end>2011-04-12 19:00:00</time_end> 
    <status>Active</status> 
    <location_name>Lake Athletic Complex</location_name> 
</event> 
<event> 
    <id>257</id> 
    <name>SB-V,SB-JV vs Jackson HS</name> 
    <time_start>2011-04-14 17:00:00</time_start> 
    <time_end>2011-04-14 19:00:00</time_end>
    <status>Active</status> 
    <location_name>Athletic Complex, HS Baseball Field</location_name>
</event>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:26:39+00:00Added an answer on May 21, 2026 at 7:26 am

    This XSLT 1.0 transformation doesn’t use modes and doesn’t have even a single conditional instruction:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="locations[1]">
      <location_name>
       <xsl:apply-templates select=
        "name | following-sibling::locations/name"/>
      </location_name>
     </xsl:template>
    
     <xsl:template match="locations"/>
    
     <xsl:template priority="5" match=
     "locations[preceding-sibling::locations]/name">
      <xsl:value-of select="concat(', ', .)"/>
     </xsl:template>
    
     <xsl:template match="locations/name[1]">
      <xsl:value-of select="."/>
     </xsl:template>
    </xsl:stylesheet>
    

    When applied on the provided XML document (wrapped in a single top element to be made well-formed)”

    <t>
        <title>Referees Events</title>
        <event>
            <id>256</id>
            <name>SB-V,SB-JV vs McKinley HS</name>
            <time_start>2011-04-12 17:00:00</time_start>
            <time_end>2011-04-12 19:00:00</time_end>
            <status>Active</status>
            <locations>
                <id>116</id>
                <name>Lake Athletic Complex</name>
            </locations>
        </event>
        <event>
            <id>257</id>
            <name>SB-V,SB-JV vs Jackson HS</name>
            <time_start>2011-04-14 17:00:00</time_start>
            <time_end>2011-04-14 19:00:00</time_end>
            <status>Active</status>
            <locations>
                <id>116</id>
                <name>Athletic Complex</name>
            </locations>
            <locations>
                <id>6</id>
                <name>HS Baseball Field</name>
            </locations>
        </event>
    </t>
    

    the wanted, correct result is produced:

    <t>
       <title>Referees Events</title>
       <event>
          <id>256</id>
          <name>SB-V,SB-JV vs McKinley HS</name>
          <time_start>2011-04-12 17:00:00</time_start>
          <time_end>2011-04-12 19:00:00</time_end>
          <status>Active</status>
          <location_name>Lake Athletic Complex</location_name>
       </event>
       <event>
          <id>257</id>
          <name>SB-V,SB-JV vs Jackson HS</name>
          <time_start>2011-04-14 17:00:00</time_start>
          <time_end>2011-04-14 19:00:00</time_end>
          <status>Active</status>
          <location_name>Athletic Complex, HS Baseball Field</location_name>
       </event>
    </t>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, I'd like to apologize in advance for not knowing this. I've been
I apologize because this topic comes up a lot, but I have not been
Programming is so new to me that I apologize for not knowing how to
I apologize if this has been asked before. I searched but did not find
I apologize if this is a duplicate but I did not find anything that
Apologies in advance for the possible flame thread, but that's not what I'm going
Greetings, Apologies in advance that I have not researched this toughly enough to answer
I apologize for asking such a generalized question, but it's something that can prove
I apologize in advance for not even knowing how to correctly phrase what I
I am very sorry that I am not able to provide more details of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.