Stage Three

How HTML attributes are generated by XSL

The format for controlling the attributes within an HTML tag is: Define the match template. Specify the HTML tag (fully closed) e.g <a> - you can add unchanging attributes within the start tag e.g. <input type="text"> - and then specify how the XML tags nested within the matching template should be assigned to the attributes required:

<xsl:attribute name="name">
<xsl:value-of select="NAME" />
</xsl:attribute>

If this template is applied using an XML file containing:

<TEXTINPUT>
<NAME>mytext2</NAME>
<SIZE>60</SIZE>
</TEXTINPUT>

the input tag would contain <input type="text" name="mytext2">

Now add the XSL code to include the size as contained in the XML file and close the template. Once this is done, you can now close the stylesheet itself (no data can be added beyond this tag) by entering:

</xsl:stylesheet>


This is part of www.codehelp.co.uk Copyright © 1998-2004 Neil Williams
See the file about.html for copying conditions.