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 7674183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:40:55+00:00 2026-05-31T16:40:55+00:00

My Orginal XML Is <?xml version=1.0 encoding=UTF-8?> <testing> <MajorEvent> <Originator>xxxx/Originator> <Version>V1</Version> </MajorEvent> <Event Date=26-03-11_04:00:00:00

  • 0

My Orginal XML Is

    <?xml version="1.0" encoding="UTF-8"?>
<testing>
    <MajorEvent>
        <Originator>xxxx/Originator>
        <Version>V1</Version>
    </MajorEvent>
    <Event Date="26-03-11_04:00:00:00" >
        <AudioName>AT1</AudioName>
        <ItemName>F7000533</ItemName>
        <Lang>
            <Languages>Language1|Language2</Languages>
        </Lang>
        <EventID>4333</EventID>
    </Event>
</testing>

I want to Produce events depending on Languages and audioname. Eg in this there are 3 events So the out put will be

    <?xml version="1.0" encoding="UTF-8"?>
        <testing>
            <MajorEvent>
                <Originator>xxxx/Originator>
                <Version>V1</Version>
            </MajorEvent>
            <Event Date="26-03-11_04:00:00:00" >
                <AudioName>AT1</AudioName>
                <ItemName>F7000533</ItemName>
                <Lang>
                    <Languages>Language1|Language2</Languages>
                </Lang>
                <EventID>4333</EventID>
            </Event>
 <Event Date="26-03-11_04:00:00:00">
    <AudioName>AT1</AudioName>
    <ItemName>F7000533-AT1</ItemName>
    <EventID>4333</EventID>
  </Event>
            <Event Date="26-03-11_04:00:00:00" >
                <AudioName>AT1</AudioName>
                <ItemName>F7000533-Language1</ItemName>
                <Lang>
                    <Languages>Language1|Language2</Languages>
                </Lang>
                <EventID>4333</EventID>
            </Event>
            <Event Date="26-03-11_04:00:00:00" >
                <AudioName>AT1</AudioName>
                <ItemName>F7000533-Language2</ItemName>
                <Lang>
                    <Languages>Language1|Language2</Languages>
                </Lang>
                <EventID>4333</EventID>
            </Event>
        </testing>

I have written the xslt.

    <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl" >
    <xsl:output method="xml" indent="yes" encoding="UTF-8" />
    <xsl:template match="/testing">
        <xsl:element name="testing">
            <xsl:apply-templates select="MajorEvent" />
            <xsl:apply-templates select="Event" />
        </xsl:element>
    </xsl:template>
    <xsl:template match="MajorEvent">
        <xsl:element name="MajorEvent">
            <xsl:copy-of select="Originator" />
            <xsl:copy-of select="Version" />
        </xsl:element>
    </xsl:template>
    <xsl:template match="Event">
        <xsl:element name="Event">
            <xsl:attribute name="Date">
                              <xsl:value-of select="@Date" />
                         </xsl:attribute>
            <xsl:copy-of select="AudioName" />
            <xsl:copy-of select="ItemName" />
            <xsl:copy-of select="EventID" />
        </xsl:element>
        <xsl:for-each select="AudioName">
            <xsl:element name="Event">
                <xsl:attribute name="Date">
                              <xsl:value-of select="../@Date" />
                            </xsl:attribute>
                <xsl:variable name="item_name" select="../ItemName" />
                <xsl:variable name="audio" select="../AudioName" />
                <xsl:copy-of select="../AudioName" />
                <xsl:element name="ItemName">
                    <xsl:value-of select="concat($item_name,'-',$audio)" />
                </xsl:element>


                <xsl:copy-of select="../EventID" />
            </xsl:element>
        </xsl:for-each>
        <xsl:variable name="SplitLanguage">
            <xsl:call-template name="SplitLanguage">
                <xsl:with-param name="Languages" select="Lang/Languages" />
            </xsl:call-template>
        </xsl:variable>
        <xsl:for-each select="exsl:node-set($SplitLanguage)/*">
            <xsl:element name="Event">
                <xsl:attribute name="Date">
                              <xsl:value-of select="Date" />
                            </xsl:attribute>
                <xsl:variable name="item_name" select="../ItemName" />
                <xsl:variable name="lang" select="." />
                <xsl:element name="ItemName">
                    <xsl:value-of select="concat($item_name,'-',$lang)" />
                </xsl:element>
            </xsl:element>
        </xsl:for-each>

    </xsl:template>
    <xsl:template name="SplitLanguage">
        <xsl:param name="Languages" select="." />
        <xsl:if test="string-length($Languages) >0">
            <item>
                <xsl:value-of select="substring-before(concat($Languages, ','), ',')" />
            </item>

            <xsl:call-template name="SplitLanguage">
                <xsl:with-param name="Languages"
                    select="substring-after($Languages, ',')" />
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>

I am getting this result

<?xml version="1.0" encoding="UTF-8"?>
<testing>
  <MajorEvent>
    <Originator>xxxx</Originator>
    <Version>V1</Version>
  </MajorEvent>
  <Event Date="26-03-11_04:00:00:00">
    <AudioName>AT1</AudioName>
    <ItemName>F7000533</ItemName>
    <EventID>4333</EventID>
  </Event>
  <Event Date="26-03-11_04:00:00:00">
    <AudioName>AT1</AudioName>
    <ItemName>F7000533-AT1</ItemName>
    <EventID>4333</EventID>
  </Event>
  <Event Date="">
    <ItemName>-Language1</ItemName>
  </Event>
  <Event Date="">
    <ItemName>-Language2</ItemName>
  </Event>
</testing>

Does anybody know what am i doing wrong here??

  • 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-31T16:40:56+00:00Added an answer on May 31, 2026 at 4:40 pm

    I don’t think you need exslt here, also you seem to be splitting on “,” rather than “|”

    <xsl:stylesheet version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:strip-space elements="*"/>
    <xsl:output indent="yes"/>
    
    <xsl:template match="/">
    <x>
    <xsl:copy-of select="/"/>
    <xsl:apply-templates select="testing/Event"/>
    </x>
    </xsl:template>
    
    <xsl:template match="Event">
     <Event Date="{@Date}">
      <xsl:copy-of select="AudioName|ItemName|EventID"/>
      </Event>
      <xsl:call-template name="splitlang">
      <xsl:with-param name="l" select="concat(Lang/Languages,'|')"/>
      </xsl:call-template>
    </xsl:template>
    
    <xsl:template name="splitlang">
    <xsl:param name="l"/>
       <xsl:choose>
       <xsl:when test="$l">
     <Event Date="{@Date}">
      <xsl:copy-of select="AudioName"/>
      <ItemName>
       <xsl:value-of select="ItemName"/>
       <xsl:text>-</xsl:text>
       <xsl:value-of select="substring-before($l,'|')"/>
      </ItemName>
      <xsl:copy-of select="Lang|EventID"/>
      </Event>
      <xsl:call-template name="splitlang">
       <xsl:with-param name="l" select="substring-after($l,'|')"/>
      </xsl:call-template>
       </xsl:when>
       </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>
    

    produces

    <x>
       <testing>
          <MajorEvent>
             <Originator>xxxx</Originator>
             <Version>V1</Version>
          </MajorEvent>
          <Event Date="26-03-11_04:00:00:00">
             <AudioName>AT1</AudioName>
             <ItemName>F7000533</ItemName>
             <Lang>
                <Languages>Language1|Language2</Languages>
             </Lang>
             <EventID>4333</EventID>
          </Event>
       </testing>
       <Event Date="26-03-11_04:00:00:00">
          <AudioName>AT1</AudioName>
          <ItemName>F7000533</ItemName>
          <EventID>4333</EventID>
       </Event>
       <Event Date="26-03-11_04:00:00:00">
          <AudioName>AT1</AudioName>
          <ItemName>F7000533-Language1</ItemName>
          <Lang>
             <Languages>Language1|Language2</Languages>
          </Lang>
          <EventID>4333</EventID>
       </Event>
       <Event Date="26-03-11_04:00:00:00">
          <AudioName>AT1</AudioName>
          <ItemName>F7000533-Language2</ItemName>
          <Lang>
             <Languages>Language1|Language2</Languages>
          </Lang>
          <EventID>4333</EventID>
       </Event>
    </x>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?xml version=1.0 encoding=utf-8?> <!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version:
<?xml version=1.0 encoding=UTF-8?> <searchResult> <pagination> <itemsPerPage>{Number of Inventories per Page}</itemsPerPage> <numberOfItems>{Number of Inventories}</numberOfItems> </pagination>
I have this resource for a Button <?xml version=1.0 encoding=utf-8?> <selector xmlns:android=http://schemas.android.com/apk/res/android> <item android:state_pressed=true>
I have a XML like this: <?xml version=1.0 encoding=UTF-8?> <nodes> <n c=value2/> <n>Has a
I have an animated rotating ImageButton. <?xml version=1.0 encoding=utf-8?> <set xmlns:android=http://schemas.android.com/apk/res/android > <rotate android:fromDegrees=0
Here is the original xml file <?xml version=1.0 encoding=utf-8?> <configuration> <setup> <cap>33</cap> </setup> <setup>
I am getting the following response from server: <?xml version=1.0 encoding=UTF-8?> <tracks type=array> <track>
This is my original xml: <?xml version=1.0 encoding=UTF-8?> <table> <row> <id>12</id> <name>Mickey Mouse</name> </row>
I have an XML document like this: <?xml version='1.0' encoding='UTF-8'?> <GateDocument> <!-- The document's
<?xml version=1.0 encoding=utf-8?> <rsp stat=ok> <image_hash>cxmHM</image_hash> <delete_hash>NNy6VNpiAA</delete_hash> <original_image>http://imgur.com/cxmHM.png</original_image> <large_thumbnail>http://imgur.com/cxmHMl.png</large_thumbnail> <small_thumbnail>http://imgur.com/cxmHMl.png</small_thumbnail> <imgur_page>http://imgur.com/cxmHM</imgur_page> <delete_page>http://imgur.com/delete/NNy6VNpiAA</delete_page> </rsp> This

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.