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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:02:34+00:00 2026-05-24T20:02:34+00:00

I want to wrap any tag that contains a href attribute into an <a>

  • 0

I want to wrap any tag that contains a href attribute into an <a> tag.

eg.

<img src="someimage.jpg" href="someurl.xml"/>

would become:

<a href="someurl.xml"><img src="someimage.jpg"/></a>
  • 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-24T20:02:35+00:00Added an answer on May 24, 2026 at 8:02 pm
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output indent="yes"/>
        <!--standard identity template that just copies content -->
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
    
        <!--For every element that has an href attribute-->
        <xsl:template match="*[@href]">
         <!--create an anchor element and an href attribute 
              with the value of the matched element's href attribute-->
            <a href="{@href}">
                       <!--then copy the matched element -->
                <xsl:copy>
                             <!--then apply templates (which will either match the 
                                  identity template above or this template,
                                  if any child elements have href attributes) -->
                    <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
            </a>
        </xsl:template>
    
        <!--redact the href attribute-->
        <xsl:template match="*/@href"/>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a new class to wrap XML handling. I want my class
Ok, basically there is a large C++ project (Recast) that I want to wrap
Suppose I want to wrap code that can throw exceptions with a try-catch block
I want to declare a function dynamically and I want to wrap any access
I have a webpage where I put a text into a pre tag that
Basically I want to be able to wrap any command in a $.holdTillFinished() method
I've got a (poorly written) base class that I want to wrap in a
When you have a class car that implements IVehicle and you want to wrap
I have a container div that contains some img tags. When I click on
I have some XML with <ListItem> elements, and I'd like to wrap any consecutive

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.