Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Starting with XML

By Neil Williams
2007-11-07


Adding custom data to the page

Applying an XML template

In the .xsl file, insert the following line in place of the entire tag that contains the data to be loaded from the XML file. e.g. for NAVIGATE, I removed the <li><a href="" title="">text</a></li> line in order to load customised settings for the href, title and text. Insert:

<xsl:apply-templates select="CODEHELP/NAVIGATE"/>

Make sure you specify the correct selection, replace CODEHELP/NAVIGATE with your main tag and the desired custom tag.

Now you need to create the template to use. At the end of the .xsl file, after the final </xsl:template> line add and customise the following extract from codehelp.xsl to match your requirements:

<xsl:template match="CODEHELP/NAVIGATE"/>
<li>
<a>
<xsl:attribute name="href">
<xsl:value-of select="FILE"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="DESC"/>
</xsl:attribute>
<xsl:value-of select="CLICK"/>
</a>
</li>

Note: The <a> tag is not left half open at the start (<a ). XML adds the attribute values inside the tag itself by matching the attribute with the value-of the XML data. To insert plain text, outside the tag, omit the xsl:attribute tags, as with the CLICK value.



Tutorial Pages:
» What is XML and why use it?
» The XML language syntax
» Converting an existing HTML site to XML
» Creating your XML stylesheet
» Adding custom data to the page
» Where's the data?
» The Test Files


Copyright © Neil Williams


 | Bookmark
Related Tutorials:
» Performing Client-Side XSL Transformations
» Create a Google Sitemap for your Web Site
» XML and Scripting Languages
» Parsing Comma-Separated Values
» XML Security Suite: Increasing the Security of E-Business
» Servlets and XML: Made for Each Other

Ask A Question
characters left.