In most cases it's pretty easy to output an element,
say something like a
<fruit-basket> tag: you just
put that tag in your template, and it gets written.
However, sometimes you need to create an element
whose name has to be computed using an XPath expression.
allows you to do this. Here are the attributes:
Specifies the name of the element you are creating.
If you want the element to be from a specific namespace, supply this attribute with the namespace as its value.
The name(s) of one or more attribute sets that this element should carry. If there are multiple attribute sets, their names should be separated by spaces.
The content of the
<xsl:element> element in
your stylesheet, after processing, becomes the content of
the generated tag.
Here are some examples. Suppose that XSLT is
processing a template that matches
<river> elements that have a
attribute. You want to generate an element whose name is
the same as the name of that attribute. You want the
content of the generated element to be the value of the node's
attribute. This would do the trick:
<xsl:element name="@salinity"> <xsl:value-of select="@flow-rate"/> </xsl:element>