Search code examples
xmljquery-mobilexslttags

Access the value of an xml tag via xsl and put this value into an XSL attribute


I have an XML file with the tag

<min>0</min>

and I am writing an XSL file, which should extract the "0" out of this tag and put it into a jQuery mobile slider like that:

<input type="range" name="slider-7" id="slider-7" value="5" min="THE ZERO I NEED" etc.../>

xsl:value-of select="" doesn't seem to do the job as it extracts the value of an attribute, not of a tag and I can't write min=xsl:value-of...

So how can I do this extraction?


Solution

  • You can use an AVT (attribute value template) with the XPath to the value you need.

    For example, if min is a child of the current context, you could do:

    <input min="{min}"/>
    

    If min is the current context, just use .:

    <input min="{.}"/>