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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:10:34+00:00 2026-05-26T07:10:34+00:00

In HTML there are tags for underlining and making bold, <u> and <b> respectively.

  • 0

In HTML there are tags for underlining and making bold, <u> and <b> respectively. Suppose I create a tag which does either of these or both, then how to interpret it using XSLT..?

For example –

<Line type="B">stackoverflow</Line>
<Line type="U">stackoverflow</Line>
<Line type="BU">stackoverflow</Line>

The HTML output should be like this –

<b>stackoverflow</b>
<u>stackoverflow</u>
<b><u>stackoverflow</b></u>

I guess this functionality will only be with XSLT part.

  • 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-26T07:10:35+00:00Added an answer on May 26, 2026 at 7:10 am

    One way to do this is with a recursive template, which recursively checks each letter of the type attribute of the line. So, to create the first element you would do the following (where $type is the variable containing the attribute value):

    <xsl:element name="{substring($type, 1, 1)}">
    

    Then you would recursively call the named template with the remaining part of the attribute value

    <xsl:call-template name="Line">
       <xsl:with-param name="type" select="substring($type, 2)"/>
    </xsl:call-template>
    

    So, given the following XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:template match="@*|node()">
          <xsl:copy>
             <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
       </xsl:template>
    
       <xsl:template match="Line" name="Line">
          <xsl:param name="type" select="@type"/>
          <xsl:choose>
             <xsl:when test="not($type)">
                <xsl:value-of select="."/>
             </xsl:when>
             <xsl:otherwise>
                <xsl:element name="{substring($type, 1, 1)}">
                   <xsl:call-template name="Line">
                      <xsl:with-param name="type" select="substring($type, 2)"/>
                   </xsl:call-template>
                </xsl:element>
             </xsl:otherwise>
          </xsl:choose>
       </xsl:template>
    </xsl:stylesheet>
    

    When applied to the following XML

    <Lines>
       <Line type="B">stackoverflow</Line> 
       <Line type="U">stackoverflow</Line> 
       <Line type="BU">stackoverflow</Line>
       <Line>No format</Line>
    </Lines>
    

    Will output the following

    <Lines>
       <B>stackoverflow</B>
       <U>stackoverflow</U>
       <B><U>stackoverflow</U></B>
       No format
    </Lines>
    

    Note, to stop the Lines element being output in this case, just add the following template to the XSLT:

    <xsl:template match="Lines">
       <xsl:apply-templates select="@*|node()"/>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to insert the ending html tags where there are missing ending tags ?
Is there a way to specify pretty-print-like formatting around HTML tags? I want to
There are lots of questions on how to strip html tags, but not many
In ASP.NET MVC is there an equivalent of the Html.ActionLink helper for Img tags?
Good morning all. Is there any jsf control that escapes the html tags? Imagine
In CSS and HTML world there are always features ( Properties/Attribute/Tags ) that would
Is there a way to directly use HTML tags in iPhone SDK? I was
There are a lot of answers for stripping HTML tags from a string, but
I found this list of HTML-Tags that are (supposedly) supported for HTML.fromHtml to create
The euro (€) is the official currency in 22 European states. In HTML there

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.