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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:25:16+00:00 2026-05-27T02:25:16+00:00

I have an input XML document something like this: <text> <p> Download the software

  • 0

I have an input XML document something like this:

<text>
    <p>
    Download the software from <link id="blah">
    </p>
</text>
    <links>
    <link id="blah">
    <url>http://blah</url>
    </link>
    </links>

And I would like my output document to be:

<text>
    <p>
    Download the software from <a href="http://blah"> http://blah </a>
    </p>
</text>

That is: I want to copy the existing input document nodes as-is but also replace certain nodes (for instance <link>) with an expanded version: based on other information contained in the input document.

I tried to use <xsl:copy .../> to first copy in the fragment like this:

<xsl:variable name="frag">
<xsl:copy-of select="text"/>
</xsl:variable>

But when I then output the variable like this:

<xsl:value-of select="$frag">

The output doesn’t appear to keep the paragraph tags ? So I’m not sure the xsl-copy has copied the nodes, or just the text somehow ?

If I place in just the following (strip out the <xsl:variable/> ‘wrapper’), it DOES preserve the tags in the output doc ?

<xsl:copy-of select="text"/>

But of course, I need to first re-map that ‘link’ tag to an anchor tag….

I haven’t even started to work out how to then replace the contents of the variable (in a new variable of course) with the link information….

  • 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-27T02:25:16+00:00Added an answer on May 27, 2026 at 2:25 am

    Try this :

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        version="1.0">
        <xsl:output indent="yes"/>
        <xsl:template match="links"/>
        <xsl:template match="*|@*">
            <xsl:copy>
                <xsl:apply-templates select="node()|@*"/>
            </xsl:copy>
        </xsl:template>
        <xsl:template match="link">
            <xsl:variable name="link" select="normalize-space(//links/link[@id = current()/@id]/url)"/>
            <a href="{$link}">
                <xsl:value-of select="$link"/>
            </a>
        </xsl:template>
    </xsl:stylesheet>
    

    With the following input :

    <?xml version="1.0" encoding="UTF-8"?>
        <texts>
            <text>
                <p>
                    Download the software from <link id="blah"/>
                </p>
            </text>
            <links>
                <link id="blah">
                    <url>http://blah</url>
                </link>
            </links>
        </texts>
    

    You get :

    <?xml version="1.0" encoding="UTF-8"?>
    <texts>
        <text>
            <p>
                Download the software from <a href="http://blah">http://blah</a>
            </p>
        </text>
    </texts>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have an XML document that looks something like this: <root> <profile> <childA>
I have this use case of an xml file with input like Input: <abc
I have saved input from a textarea element to a TEXT column in MySQL.
Let's say i have a full html-document as XML-input. How would the XSLT-file look
I have an XML document on input which is awfully formatted (it's Delphi project
I have a BizTalk schema that looks something like this: <Root> <Header> <SomeData></SomeData> <Detail>
I need to remove attribute from XML document by this attribute's XPath. Everything should
I have an input document of XML data that will resolve nicely into data
I have rather large input XML files that must be converted to a given
I have an XML input file and I'm trying to output the result of

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.