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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:05:45+00:00 2026-05-31T17:05:45+00:00

I have an XML file which has to be transformed using XSLT, I am

  • 0

I have an XML file which has to be transformed using XSLT, I am adding a node to a subtree.
The input file is as follows:

 <?xml version="1.0" encoding="UTF-8"?>
    <Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Context>
    <ContextExtra>
        <ns3:timestampList xmlns:ns3="http://www.mydomain.com/myAdapter/basicMessage/1.0" 
                           xmlns:ns2="http://www.mydomain.com/myAdapter/tbMessage/1.0" 
                           xmlns="http://www.mydomain.com/myAdapter/timestamp/1.0" 
                           xmlns:ns10="http://www.mydomain.com/myAdapter/coMessage/1.0" 
                           xmlns:ns11="http://www.mydomain.com/myAdapter/lolMessage/1.0" 
                           xmlns:ns12="http://www.mydomain.com/myAdapter/tcMessage/1.0" 
                           xmlns:ns13="http://www.mydomain.com/myAdapter/bMessage/1.0" 
                           xmlns:ns4="http://www.mydomain.com/myAdapter/tiMessage/1.0" 
                           xmlns:ns5="http://www.myDomain.com/myAdapter/oriMessage/1.0" 
                           xmlns:ns6="http://www.myDomain.com/myAdapter/eiMessage/1.0" 
                           xmlns:ns7="http://www.myDomain.com/myAdapter/fplscMessage/1.0" 
                           xmlns:ns8="http://www.myDomain.com/myAdapter/psMessage/1.0" 
                           xmlns:ns9="http://www.myDomain.com/myAdapter/stMessage/1.0">
            <timestampInfo>
                <timestampID>START</timestampID>
                <timestamp>2012-02-25T00:30:18.705+01:00</timestamp>
                <description xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
            </timestampInfo>
            <timestampInfo>
                <timestampID>END</timestampID>
                <timestamp>2012-02-25T00:30:23.675+01:00</timestamp>
                <description xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
            </timestampInfo>
        </ns3:timestampList>

    </ContextExtra>
</Context>

The transformation looks like this

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:output method="xml" indent="yes" />    

<xsl:param name="newTimeStamp">
    <timestampInfo>
        <timestampID>
            <xsl:text>TEST TEST</xsl:text>
        </timestampID>
        <timestamp>
            <xsl:text>2012-02-25T00:30:23.654+01:00</xsl:text>
        </timestamp>
        <description>
            <xsl:text>this is a test</xsl:text>
        </description>
    </timestampInfo>
</xsl:param>

<xsl:template match="//ts:timestampInfo[position()=last()]">
    <xsl:call-template name="identity" />
    <xsl:copy-of select="$newTimeStamp" />
</xsl:template>

<xsl:template match="node()|@*" name="identity">
    <xsl:copy>
        <xsl:apply-templates select="node()|@*" />
    </xsl:copy>
</xsl:template>

and the result is as follows:

<?xml version="1.0" encoding="UTF-8"?>
 <Envelope>
<Context>
    <ContextExtra>
        <ns3:timestampList xmlns="http://www.myDomain.com/myAdapter/timestamp/1.0" xmlns:ns3="http://www.myDomain.com/myAdapter/basicMessage/1.0">
            <timestampInfo>
                <timestampID>MTA_START</timestampID>
                <timestamp>2012-02-25T00:30:18.705+01:00</timestamp>
                <description xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
            </timestampInfo>
            <timestampInfo>
                <timestampID>MTA_END</timestampID>
                <timestamp>2012-02-25T00:30:23.675+01:00</timestamp>
                <description xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
            </timestampInfo>
            <timestampInfo xmlns="">
                <timestampID>TEST TEST</timestampID>
                <timestamp>2012-02-25T00:30:23.654+01:00</timestamp>
                <description>This is a test</description>
            </timestampInfo>
        </ns3:timestampList>
    </ContextExtra>
</Context>

As you can see timestampInfonodes have as attribute xmlns="". That is, it is an empty namespace generated. Instead of <timestampInfo xmlns=""> I would like to have nodes of the form <timestampInfo>. The input file has this format and I have no control over it.

How I can achieve this?

Thanks in advance

  • 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-31T17:05:46+00:00Added an answer on May 31, 2026 at 5:05 pm

    Specify the namespace of the timestampInfo you are adding:

    <xsl:param name="newTimeStamp"> 
        <timestampInfo xmlns="http://www.myDomain.com/myAdapter/timestamp/1.0"> 
            <timestampID> 
                <xsl:text>TEST TEST</xsl:text> 
            </timestampID> 
            <timestamp> 
                <xsl:text>2012-02-25T00:30:23.654+01:00</xsl:text> 
            </timestamp> 
            <description> 
                <xsl:text>this is a test</xsl:text> 
            </description> 
        </timestampInfo> 
    </xsl:param> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which looks like this : <?xml version=1.0 encoding=UTF-8?> <resultset
I have a XML file which has a node which is commented out. I
I have an XML file which has many section like the one below: <Operations>
I have a very large XML file which has like 40000 data, and when
I have parsed XML file into objects, in which each object has a 1:1
I have an XML file that has a number of nodes, each of which
I have an XML file which I need to parse using PHP and send
Im using c# .net , windows form application. I have a XML file which
I have a questions.xml file which has a list of questions for my quiz,
I have the following mapping in my Castle Windsor xml file which has worked

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.