Corey
Corey

Reputation:

setting the style attribute of a li element using xsl

I'm using an XSL file to transform a XML file to a XHTML file. I am trying to create an element li and set the "style" attribute to the value "hello:"

<li><xsl:attribute name="style">hello</xsl:attribute></li>

I get:

<li style=""></li>

But was expecting to get:

<li style="hello"></li>

Anybody have any idea what's going on?

Upvotes: 0

Views: 10929

Answers (2)

Jeet
Jeet

Reputation: 31

You can work this out with following way

<xsl:attribute name="class">
   <xsl:value-of select="'selected'"/>
</xsl:attribute>

The above example is for adding class to the li tag. If you are too specific for using the style tag inside li then use

<xsl:attribute name="style">
   <xsl:value-of select="'color:green;'"/>
</xsl:attribute>

Upvotes: 3

Alohci
Alohci

Reputation: 83006

It seems Firefox checks the values going into the style attribute. if you put "color:red", for example, instead of "hello", that will be accepted into the style attribute. Invalid css is discarded.

It may depend on how exactly you are inspecting the contents of the style attribute, since its hard to see the result of the transformation without inspecting the DOM, which will be a sanitized version of the transformation.

Upvotes: 1

Related Questions