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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:34:52+00:00 2026-05-13T00:34:52+00:00

Using XSL I am trying to turn this XML: <book><title>This is a <b>great</b> book</title></book>

  • 0

Using XSL I am trying to turn this XML:

<book><title>This is a <b>great</b> book</title></book>

into this XML:

<book>This is a <bold>great</bold> book</book>

using this xsl:

<xsl:for-each select="book/title/*">
<xsl:choose>
    <xsl:when test="name() = 'b'">
        <bold>
            <xsl:value-of select="text()"/>
        </bold>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="text()"/>
    </xsl:otherwise>
</xsl:choose>
</xsl:for-each>

but my output is looking like this:

<book><bold>great</bold></bold>

Can anyone explain why the root text of <title> is getting lost? I believe my for-each select statement may need to be modified but I can’t figure out what is should be.

Keep in mind that I cannot use an <xsl:template match> because of the complexity of my style sheet.

Thanks!

  • 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-13T00:34:53+00:00Added an answer on May 13, 2026 at 12:34 am

    This XPath expression:

    book/title/*
    

    means “all child elements of book/title“. In your case, book/title has 3 child nodes:

    • Text node: This is a
    • Element node: <b>...</b>
    • Text node: book

    As you can see, only one of them is an element, and gets selected. If you want to get all child nodes, both text and elements, use this:

    book/title/node()
    

    If you want to get text nodes separately, use this:

    book/title/text()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to remove the attribute xmlns=http://webdev2003.test.com from the following xml using xsl/xslt,
Im trying to transform an XML document into XHTML using XSL transformation and was
I'm trying to transform one XML format to another using XSL. Try as I
I am trying to sort an xml using xsl. Got some sample from xml.com.
I am trying to write a breadcrumb navigation by using XSL to transform XML.
Trying to combine an if statement using <xsl:if test=expression> where I want to have
I'm trying to query an xml file using the following xslt: <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform
I am trying to generate a PDF using XSL(XML-FO) to transform a generated XML
I am trying to modify a proprietory XML file using XSL and MSXSL. The
I am trying to insert xml elements into an xml file using XSLT. I

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.