Last post Mar 01, 2015 09:36 PM by Zhi Lv - MSFT
Feb 27, 2015 05:01 PM|lesponce|LINK
I need to be able to assign a class attribute to an HTML Body tag using XSLT. The Body tag is coming from a SharePoint Master Page. Therefore, I need to add the class attribute or override the Body tag so I can have the class included.
The HTML Output result should be set just like the following example:
<xsl:variable name="ABC" select="ABCStyle" />
Feb 27, 2015 05:07 PM|lesponce|LINK
I'm getting the variable value from a SharePoint List. It is working and I have been able to work with those values. I just need to add the value, for example ABC as a class attribute to the Body tag.
Mar 01, 2015 09:36 PM|Zhi Lv - MSFT|LINK
I just need to add the value, for example ABC as a class attribute to the Body tag.
As for this issue, I suggest you could try to use the <xsl:attribute> element to add attributes to elements.
You could try to use the solution which is contained in
<before theme-children="/html/body" method="raw">
<xsl:attribute name="class"><xsl:value-of select="/html/body/@class" /><xsl:if css:test="#portal-column-one"> col-one</xsl:if><xsl:if css:test="#portal-column-content"> col-content</xsl:if><xsl:if css:test="#portal-column-two"> col-two</xsl:if></xsl:attribute>
Here are some relevant articles, please refer to them.
Generate dynamic ASP.NET pages by using XML and XSLT
Add attribute to tag with XSLT
How to set attribute in XML using XSLT?