Wednesday, February 9, 2011

XML add <a> hyperlink

Hi,

I have a xml blob that's checked against a schema in sql 2005. My website uses xsl to transform and display the blob. How do I add a hyperlink to the xml (in any node) without the sql 2005 schema complaining a node was found in the wrong place? Or the xsl thinking that the hyperlink is a valid xml node?

thank you

  • I'm guessing you aren't encoding the < and > characters correctly. You need to use &lt; and &gt;

    Paulj : awesome, thanks.
    Josh : No it's
  • For more advanced html building, you may need to use the xsl:element tag:

      <xsl:element name="a">
        <xsl:attribute name="href">http://www.stackoverflow.com</xsl:attribute>
        Click here
      </xsl:element>
    

    renders

    <a href="http://www.stackoverflow.com">Click here</a>
    

    The nice thing about this is that the values for any of the "name" attributes or inner text can be computed xsl values.

0 comments:

Post a Comment