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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:58:25+00:00 2026-06-11T10:58:25+00:00

I have the following XML (Much of the data is dummy) <?xml version=1.0 encoding=UTF-8?>

  • 0

I have the following XML (Much of the data is dummy)

<?xml version="1.0" encoding="UTF-8"?>
<msg xmlns="http://someaddress.com/m1"  xmlns:ds="http://www.w3.org/2000/09/xmldsig#"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://someaddress/somexsd.xsd">
<header>
    <nodeA>aaaaaaaaaaa</nodeA>
    <nodeB>bbbbbbbb</nodeB>
</header>
<payload>
    <calcnode   xmlns="http://someaddress/nodeC"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://someaddress/somexsd.xsd">
        <somefield>field</somefield>
    </calcnode>
    <ds:Signature>
        <SignedInfo>
            <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
            <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
            <Reference URI="#kjbn34jkb5j-3k45j-k3jb534jkb534k5">
                <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                <DigestValue>+se0dfgft9gh8hjuji7ji65ko4ko3ko2</DigestValue>
            </Reference>
        </SignedInfo>
        <SignatureValue>sekfrhsdkjfhsdkjfhksd</SignatureValue>
        <KeyInfo>
            <X509Data>
                <X509Certificate>sdjkfhsdkfhskdf</X509Certificate>
            </X509Data>
        </KeyInfo>
    </ds:Signature>
</payload>
</msg>

And all I want to do is change the name of the msg element (to newmsg) and the default namespace to http://someaddress.com/m2. Everything else should be kept as is. the closest I have been able to get is this xslt

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msg="http://someaddress.com/m1" >

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

<!-- replace namespace of elements in old namespace -->
<xsl:template match="msg:msg">
  <xsl:element name="newmsg" namespace="http://someaddress.com/m2">
     <xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

I am using xalan for testing and this is the output xml I get when running the above

<?xml version="1.0" encoding="UTF-8"?>
    <newmsg xmlns="http://someaddress.com/m2" xsi:schemaLocation="http://someaddress/somexsd.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header xmlns="http://someaddress.com/m1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <nodeA>aaaaaaaaaaa</nodeA>
    <nodeB>bbbbbbbb</nodeB>
</header>
<payload xmlns="http://someaddress.com/m1" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <calcnode xmlns="http://someaddress/nodeC" xsi:schemaLocation="http://someaddress/somexsd.xsd">
        <somefield>field</somefield>
    </calcnode>
    <ds:Signature>
        <SignedInfo>
            <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
            <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
            <Reference URI="#kjbn34jkb5j-3k45j-k3jb534jkb534k5">
                <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                <DigestValue>+se0dfgft9gh8hjuji7ji65ko4ko3ko2</DigestValue>
            </Reference>
        </SignedInfo>
        <SignatureValue>sekfrhsdkjfhsdkjfhksd</SignatureValue>
        <KeyInfo>
            <X509Data>
                <X509Certificate>sdjkfhsdkfhskdf</X509Certificate>
            </X509Data>
        </KeyInfo>
    </ds:Signature>
</payload>
</newmsg>

There are 2 main problems with this:

  1. The ds namespace simply disappears from the output and I don’t know why.
  2. The second issue is that it drops the xsi namespace from the calcnode and given that the calcnode is the node used to calculate (and verify) the signature (Which comes below that section) such change would make verification of the signature impossible to my understanding.

I have tried several different iterations of the xslt without much results. Could anybody shed some light in the situation?

  • 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-06-11T10:58:26+00:00Added an answer on June 11, 2026 at 10:58 am

    This transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:oldDef="http://someaddress.com/m1" exclude-result-prefixes="oldDef">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="*">
      <xsl:element name="{name()}" namespace="{namespace-uri()}">
       <xsl:copy-of select="namespace::*[name()]|@*"/>
       <xsl:apply-templates select="node()"/>
      </xsl:element>
     </xsl:template>
    
     <xsl:template match="*[namespace-uri()='http://someaddress.com/m1']">
      <xsl:element name="{name()}" namespace="http://someaddress.com/m2">
       <xsl:copy-of select="namespace::*[name()]"/>
       <xsl:copy-of select="@*"/>
       <xsl:apply-templates select="node()"/>
      </xsl:element>
     </xsl:template>
    
     <xsl:template match="oldDef:msg[true()]">
      <newmsg xmlns="http://someaddress.com/m2">
       <xsl:copy-of select="namespace::*[name()]|@*"/>
       <xsl:apply-templates select="node()"/>
      </newmsg>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <msg xmlns="http://someaddress.com/m1"  xmlns:ds="http://www.w3.org/2000/09/xmldsig#"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://someaddress/somexsd.xsd">
    <header>
        <nodeA>aaaaaaaaaaa</nodeA>
        <nodeB>bbbbbbbb</nodeB>
    </header>
    <payload>
        <calcnode   xmlns="http://someaddress/nodeC"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://someaddress/somexsd.xsd">
            <somefield>field</somefield>
        </calcnode>
        <ds:Signature>
            <SignedInfo>
                <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
                <Reference URI="#kjbn34jkb5j-3k45j-k3jb534jkb534k5">
                    <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                    <DigestValue>+se0dfgft9gh8hjuji7ji65ko4ko3ko2</DigestValue>
                </Reference>
            </SignedInfo>
            <SignatureValue>sekfrhsdkjfhsdkjfhksd</SignatureValue>
            <KeyInfo>
                <X509Data>
                    <X509Certificate>sdjkfhsdkfhskdf</X509Certificate>
                </X509Data>
            </KeyInfo>
        </ds:Signature>
    </payload>
    </msg>
    

    produces the wanted, correct result:

    <newmsg xmlns="http://someaddress.com/m2" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://someaddress/somexsd.xsd">
       <header>
          <nodeA>aaaaaaaaaaa</nodeA>
          <nodeB>bbbbbbbb</nodeB>
       </header>
       <payload>
          <calcnode xmlns="http://someaddress/nodeC" xsi:schemaLocation="http://someaddress/somexsd.xsd">
             <somefield>field</somefield>
          </calcnode>
          <ds:Signature>
             <SignedInfo>
                <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
                <Reference URI="#kjbn34jkb5j-3k45j-k3jb534jkb534k5">
                   <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                   <DigestValue>+se0dfgft9gh8hjuji7ji65ko4ko3ko2</DigestValue>
                </Reference>
             </SignedInfo>
             <SignatureValue>sekfrhsdkjfhsdkjfhksd</SignatureValue>
             <KeyInfo>
                <X509Data>
                   <X509Certificate>sdjkfhsdkfhskdf</X509Certificate>
                </X509Data>
             </KeyInfo>
          </ds:Signature>
       </payload>
    </newmsg>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XML Document: <?xml version=\1.0\ encoding=\UTF-8\?> <atom:entry xmlns:atom=\http://www.w3.org/2005/Atom\ xmlns:apps=\http://schemas.google.com/apps/2006\ xmlns:gd=\http://schemas.google.com/g/2005\> <apps:property
I have the following xml - <Surveys xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=ImmForm XML Schema NHS Direct.xsd><Svy SurveyName=WeeklyFluSurveillance2012/13-NHSDirectWeek40w/e07/10/2012
I have the following plist file at ~/Library/LaunchAgents: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC
I have the following (as an example) XML file and XSD. <?xml version=1.0 encoding=utf-8
I have following XML, and i wish to save its data in my SQL
jqGrid v4.3.2 ie9 win7enterprise I'm using the following code to generate subgrids: http://www.trirand.com/blog/jqgrid/jqgrid.html -
I have following xml and I want to fetch the value of node which
I have following XML. I was able to remove all namespaces but not able
I have following xml file: <ab> <![CDATA[ <table> <tbody> <tr> <th>abcdef</th> </tr> <tr> <p>
I have following xml as a response to a service not i want to

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.