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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:36:08+00:00 2026-06-03T02:36:08+00:00

I currently have a simple markup which mostly represents HTML. Below is a snippet

  • 0

I currently have a simple markup which mostly represents HTML.

Below is a snippet of that

<li>Make this <b>Bold</b></li>

I can of course use <xsl:copy-of> to ensure that the <b> tag is passed through and is automatically displayed as bold, however I have a problem.

I am using another XSL which checks the markup against a repository of keywords or phrases and if they exist, links are created.

Below is my XSL

<xsl:template name="List" match="li">
  <li>
          <xsl:call-template name="markup">
            <xsl:with-param name="text" select="."/>
            <xsl:with-param name="phrases" select="document('../../documents/main/keywords.xml')/keywords/keyword"/>
            <xsl:with-param name="first-only" select="false()"/>
          </xsl:call-template>
  </li>
  </xsl:template>

This method prevents any child tags being passed through, however I am unsure as to how I can get around this.

Any help is greatly appreciated!
Dan

  • 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-06-03T02:36:10+00:00Added an answer on June 3, 2026 at 2:36 am

    The problem is that your link-creating template does the wrong thing.

    The right thing to do is using the identity template and creating a dedicated template for text node descendants of <li> elements.

    Try this:

    <xsl:variable 
      name="keywords"
      select="document('../../documents/main/keywords.xml')/keywords/keyword" 
    />
    
    <!-- the identity template does copies of everything not matched otherwise -->
    <xsl:template match="node() | @*">
      <xsl:copy>
        <xsl:apply-templates select="node() | @*" />
      </xsl:copy>
    </xsl:template>
    
    <!-- text nodes in <li> elements get special treatment -->
    <xsl:template match="li//text()">
      <xsl:call-template name="markup">
        <xsl:with-param name="phrases" select="$keywords"/>
        <xsl:with-param name="first-only" select="false()"/>
      </xsl:call-template>
    </xsl:template>
    
    <!-- marks up the current node -->
    <xsl:template name="markup">
      <xsl:with-param name="phrases" />
      <xsl:with-param name="first-only" select="true()" />
    
      <!-- you can use . here - no need to pass in a $text param -->
    </xsl:template>
    

    The identity template is the key to successfully solving problems like this one. It handles copying the <li> and the <b> transparently.

    1. It does a full traversal of the input, copying it unless a more specific template matches the current node.
    2. This means you only need to write templates for nodes you want to change. In this case matching text nodes works best, since they cannot have nested children.
    3. Avoid named templates like <xsl:template name="List">. This is “push style” XSLT, i.e. it’s imperative and often leads to pretty clumsy results.
    4. The <xsl:template match="li//text()"> pulls nodes out of the stream and does something more complex than just copying them. This is “pull style” XSLT, i.e. template matching. It usually is easier to handle and produces cleaner XSLT code.
    5. You are not constrained to text nodes within <li> elements, of course. Just change the match expression to affect other nodes.

    Say you want to turn all <b> nodes into <strong> without disrupting any other templates. With pull style, this is as easy as this:

    <xsl:template match="b">
      <strong>
        <xsl:apply-templates select="node() | @*" />
      <strong>
    </xsl:template>
    

    Also note that the current node does not change when you do <xsl:call-template>. Therefore there is no need to pass in the current node to a called template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a simple form that when you click the save button will
Currently I have a simple knockoutJS object, with a few observables. But this object
Currently I have a simple maven project that is building a jar file and
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have a very simple interface which needs to communicate between processes. It's currently
I currently have a simple list view adapter that holds two rows of text.
I currently have a simple iPhone app that loads a custom subclass of UIView.
I have created a very simple markup parser in php. However, it currently uses
I have a semi-working example that you can look at. This appears to work
I currently have a simple app that includes user authentication through devise and a

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.