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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:40:44+00:00 2026-05-19T17:40:44+00:00

pros, I need to convert the ‘B’ tag with ‘X’ tag in the following

  • 0

pros,
I need to convert the ‘B’ tag with ‘X’ tag in the following document:

<a>
 <B marker="true">
  <c>
    <B marker="true">
      <d>
        <B marker="true">
        </B>
       <d>
    </B>
  </c>
 </B>
</a>

Note the reoccurring ‘B’, it can appear at any depth in dynamic XML.
Here’s what I did:

<xsl:template match="//*[@marker='true']">
    <X>
        <xsl:copy-of select="./node()"/>
    </X>
</xsl:template>

It worked for the top-most ‘B’ tag, but ignored all the nested ones.

I think I know what the problem is – ‘copy-of’ just flushes the content of the top-most ‘B’ tag, without evaluating it. What can I do to make ‘copy-of’ reevaluate my template?

Thanks!
Baruch.

  • 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-19T17:40:45+00:00Added an answer on May 19, 2026 at 5:40 pm

    I would go with identity transform.

    This code:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>
    
        <xsl:template match="@* | node()">
            <xsl:copy>
                <xsl:apply-templates select="@* | node()"/>
            </xsl:copy>
        </xsl:template>
    
        <xsl:template match="B[@marker = 'true']">
            <X>
                <xsl:apply-templates/>
            </X>
        </xsl:template>
    </xsl:stylesheet>
    

    Against this XML input:

    <a>
        <B marker="true">
            <c test="test">
                testText
                <B marker="true">
                    <d>
                        testText2
                        <B marker="true">
                            testText3
                        </B>
                    </d>
                </B>
                testText4
            </c>
            testText5
        </B>
    </a>
    

    Will provide this correct result:

    <a>
        <X>
            <c test="test">
                testText
                <X>
                    <d>
                        testText2
                        <X>
                            testText3
                        </X>
                    </d></X>
                testText4
            </c>
            testText5
        </X>
    </a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to do the following: Select ProID from Pros ps where ps.ProId =
What are the pros and cons of using either of the following approaches to
Can anybody please put some light on the need of the method getTypeInstance(), which
Facing a need for a single CMS we can use for rapid deployment of
noob here and need help from the pros... i am doing a voice record
I need to make a css navigation according to the following style: DESIRED LOOK
pros! Looks like basic question, but I just can't find what I am looking
I need a note taking wiki-like super application. I'll start with a rundown of
I need to create a message system, where a person can have a conversation
Sorry if the title didn't make any sense. Currently, the following parameters on the

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.