User501
User501

Reputation: 347

Need the URL coming in both attribute and content

My input is having URL, this needs to come in both attribute value and content value in the output using XSL:

My Input xml is:

<link>
<Url>http://tneb.gov/</Url>
</link>

XSL I Used as:

<xsl:stylesheet version="2.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="Url">
    <xsl:element name="xref">
      <xsl:attribute name="format">
        <xsl:text>html</xsl:text>
      </xsl:attribute>
      <xsl:attribute name="href">
        <xsl:value-of select="ancestor-or-self::link/Url"/>
      </xsl:attribute>
     </xsl:element>
   </xsl:template>

</xsl:stylesheet>

Output I get as:

<xref format="html" href="http://tneb.gov/"/>

But i need as:

<xref format="html" href="http://tneb.gov/">http://tneb.gov/</xref>

Please give me suggestion on this. Thanks in advance

Upvotes: 0

Views: 55

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116993

Why don't you do simply:

<xsl:template match="Url">
    <xref format="html" href="{.}">
        <xsl:value-of select="."/>
    </xref>
</xsl:template>

Notes:

Upvotes: 1

Related Questions