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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:40:28+00:00 2026-05-15T08:40:28+00:00

I have a tricky XSL problem at the moment. I need to copy the

  • 0

I have a tricky XSL problem at the moment.
I need to copy the existing XML, copy a certain element (plus its child elements) and modify the value of two child-elements.
The modifications are: divide value of the ‘value’ element by 110 and edit the value of the ‘type’ element from ‘normal’ to ‘discount’.

This is currently what I have:

Current XML:

<dataset>
  <data>
   <prices>
    <price>
      <value>50.00</value>
      <type>normal</type>
    </price>
  </prices>
 </data>
</dataset>

Expected result

<dataset>
  <data>
   <prices>
    <price>
      <value>50.00</value>
      <type>normal</type>
    </price>
    <price>
      <value>45.00</value>
      <type>discount</type>
    </price>
  </prices>
 </data>
</dataset>

Any takers?
I’ve gotten as far as copying the desired ‘price’ element using copy-of, but I’m stuck as to how to modify it next.

  • 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-15T08:40:28+00:00Added an answer on May 15, 2026 at 8:40 am

    Your spec is a little off — your value is the result of multiplying by .9, not dividing by 110. The below assumes you want to edit everything with a “normal” price — change the template match pattern for your particular node or set of nodes.

    <xsl:stylesheet version="1.0" 
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:output method="xml"/>
    
      <xsl:template match="/dataset/data/prices/price[type='normal']">
        <xsl:apply-templates/>
        <xsl:copy>
          <value><xsl:value-of select="format-number(value * 0.9, '0.00')"/></value>
          <type>discount</type>
        </xsl:copy>
      </xsl:template>
    
      <xsl:template match="@*|node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I have a pretty tricky regex problem. I need to match and replace
I have a tricky problem. I am in a situation where I need to
I have a tricky problem that has had me scratching my head for a
I seem to have a tricky problem since the latest ADT update to release
I have a very tricky problem going on with content inside a textarea on
I have the following tricky problem: I have implemented a (rather complicated) class which
I have sort of a tricky problem I'm attempting to solve. First of all,
I have run into a bit of a tricky problem in some C++ code,
I have a tricky problem with SSRS. One of my users had his AD
I have a tricky problem and I'm not sure where in the view rendering

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.