Creating Elements and Attributes

Thus far, this chapter has shown how you can control the overall style sheet using top-level elements such as <xsl:output>, create template rules and invoke them using the <apply-templates> instruction element, and get element content and attribute values using <xsl:value-of>. It’s time to look toward more interesting tasks.

When you’ve mastered the basics, the first thing you will likely want to do is begin creating your own elements and attributes for insertion into the result tree. Let’s look at the process of creating an element first.

You create a new element using <xsl:element>, like so:

<xsl:element name=”companyName”> 
      Beyond HTML 
</xsl:element> 

The name attribute provides the name for the element you ...

Get Special Edition Using XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.