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 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 nodes of the input document as is, but also replace some nodes (for example, <link>
) with the extended version: based on other information contained in the input document.
I tried using <xsl:copy .../>
to first copy the fragment as follows:
<xsl:variable name="frag"> <xsl:copy-of select="text"/> </xsl:variable>
But when I output the variable like this:
<xsl:value-of select="$frag">
Does the output not contain paragraph tags? So I'm not sure if xsl-copy copied the nodes or just text somehow?
If I add only the following (remove the "wrapper" <xsl:variable/>
), will it save the tags in the output?
<xsl:copy-of select="text"/>
But, of course, I need to first reassign this 'link' tag to the anchor tag ....
I did not even begin to figure out how then to replace the contents of the variable (in the new variable, of course) with the link information ....
source share