Search

I have a percentage bar on my website and I need to parse the value from data source to an html tag.

<div style="width: 5%;"></div>

<xsl:value-of select="percentfull"/>

What I'm trying to do is:

<div style="width: <xsl:value-of select="percentfull"/>%;"></div>

Thanks for any help :)

Easy, you can put any XSL you like inside an xsl:attribute tag to put the result in an html-attribute.

<div>
    <xsl:attribute name="style">
         <xsl:text>width: </xsl:text><xsl:value-of select="percentfull"/><xsl:text>;</xsl:text>
    </xsl:attribute>
</div>

Or, even simpler:

<div style="width:{percentfull}%"></div>

{percentfull}

Which is called Attribute Value Template (AVT) — I've learned that from Allen.

I've learned that from Allen.

And all this wisdom is then spread out to the rest of the world. Thank you internet!

DO YOUR EXAMS.

:-)

I was breaking my head over this for days thanks guys awesome community!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details