Page 1 of 1

Setting values in XSL documents

Posted: Fri Aug 12, 2005 6:32 am
by anjanesh
Im trying out XSL.

Code: Select all

<xsl:element name="a">
 <xsl:attribute name="style">
  // What do to for color:blue;text-decoration:none
 </xsl:attribute>
</xsl:element>
How do I change style properties - say color:blue;text-decoration:none ?

Thanks

Posted: Fri Aug 12, 2005 10:15 am
by timvw

Code: Select all

<a>
<xsl:attribute-set>
  <xsl:attribute name="font-weight">bold</xsl-attribute>
  <xsl:attribute name="style">color:blue;text-decoration:none</xsl:attribute>
</xsl:attribute-set>
</a>

Posted: Fri Aug 12, 2005 2:13 pm
by anjanesh
Thanks. So this is how it works.
Is there a method to include Javascript methods for tags ?

Using href :

Code: Select all

<xsl:attribute name="href">
     <xsl:value-of select="$ClickUrl" />
    </xsl:attribute>
I tried to replace this with onclick (will javascript attributes / methods get parsed by xls ? )

Code: Select all

<xsl:attribute name="onclick">
      // What to do to insert window.open('$ClickUrl')
     </xsl:attribute>
Thanks

Posted: Fri Aug 12, 2005 3:52 pm
by timvw
I can only advise to test it yourself.. ;)

If you want "special" entities in your value, you will have to use htmlentities are CDATA to escape it.

Code: Select all

<xsl:attribute name="bar">htmlentities("<foo/>")</xsl:attribute>
<xsl:attribute name="bar"><![CDATA[ <foo/> ]]></xsl:attribute>