Appending a class attribute to Ephox output

Hi there,

I need to append a ‘class’ attribute to the first tag (whatever one it happens to be) in the body text (which is handled by Ephox). For example if the content returned by Ephox happens to be ‘<p>Some text…’ then I need it to be modified to ‘<p class=“xmfix”>Some text…’ before going into the d/b.

Via the old forum I’ve found out the place for any user-contributed XSLT manipulation to Ephox happens in Rhythmyx/rx_resources/stylesheets/assemblers/rx_Inlinelinks.xsl

I’ve also more or less figured out that the required XSL probably should look like this:

<xsl:template match="[1]" mode=“rxbodyfield”>
<xsl:copy>
<xsl:copy-of select="@
"/>
<xsl:attribute name=“class”>xmfix</xsl:attribute>
</xsl:copy>
</xsl:template>

Problem is, it doesn’t work when I try to assemble and preview pages in Rx. Where am I going wrong?

I use Rx 6.1.

Oops, hadn’t noticed all code in my first post had got stripped out. Anyway, Nabeel, one of the consultants, gave me the solution, and it doesn’t involve going into XSLT. Instead a user-defined Velocity macro handles the job in the following manner:

#macro(bodyfield $fieldname)
	#__handlefieldaa($fieldname)
	#set($body = $sys.item.getProperty($fieldname).String)
	#set($endoffirsttag = $body.indexOf(">"))
	#set($beforeclass = $body.substring(0, $endoffirsttag))
	#set($afterclass = $body.substring($endoffirsttag, $body.length()))
	$beforeclass class="xmfix"$afterclass
#end