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

  • Home
  • SEARCH
  • 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 1027717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:16:45+00:00 2026-05-16T12:16:45+00:00

I have an XML document that has an XML node named Description The Description

  • 0

I have an XML document that has an XML node named “Description”

The Description node contains text like “This is a long description.”

When the XML file is loaded and displays in a browser, I need just the word “long” to be italicized. I understand that I could use XSLT to style the entire Description node, but how do I use CSS styling on only a small part of the node content?

  • 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-16T12:16:46+00:00Added an answer on May 16, 2026 at 12:16 pm

    This XSLT 1.0 stylesheet:

    <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="text()[ancestor::Description]" name="replace">
            <xsl:param name="pString" select="."/>
            <xsl:choose>
                <xsl:when test="contains($pString,' long ')">
                    <xsl:value-of select="substring-before($pString,' long ')"/>
                    <i> long </i>
                    <xsl:call-template name="replace">
                        <xsl:with-param name="pString" 
                        select="substring-after($pString,' long ')"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$pString"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    </xsl:stylesheet>
    

    With this input:

    <Description>This is a long description</Description>
    

    Output:

    <Description>This is a<i> long </i>description</Description>
    

    And this XSLT 2.0 stylesheet:

    <xsl:stylesheet version="2.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="text()[ancestor::Description]">
            <xsl:analyze-string select="." regex="([\p{{P}}\p{{Z}}])long([\p{{P}}\p{{Z}}])">
                <xsl:matching-substring>
                    <xsl:value-of select="regex-group(1)"/>
                    <i>long</i>
                    <xsl:value-of select="regex-group(2)"/>
                </xsl:matching-substring>
                <xsl:non-matching-substring>
                    <xsl:value-of select="."/>
                </xsl:non-matching-substring>
            </xsl:analyze-string>
        </xsl:template>
    </xsl:stylesheet>
    

    Output:

    <Description>This is a <i>long</i> description</Description>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 501k
  • Answers 501k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Make sure that you're removing the copy of the driver… May 16, 2026 at 2:21 pm
  • Editorial Team
    Editorial Team added an answer A backslash at the end of the line will indicate… May 16, 2026 at 2:21 pm
  • Editorial Team
    Editorial Team added an answer !== is more strict than !=, !== also check the… May 16, 2026 at 2:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a document that transforms xml to word. it starts like this: <?xml
I'm parsing an XML document that has nodes like the following: <objects> <dog> <data1>...</data1>
New to XML. I have a 3rd party webservice that supplies an XML document
Picture the following situation. I have an XML document as follows, <Form> <Control Type=Text
I have an XML Document with Nodes that can appear recursively within other nodes
I am parsing an XML document. I have done this thousands of times before,
Is there an xpath way to find a node that has a given attribute
I have an xml document with a root element, two child elements, 'diagnostic' and
I have an XML document, want to do syntax highlighting. The code uses XPathDocument
I have a Treeview where on selecting a node the attributes and values has

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.