Re: [xsl] Adding Missing Elements

Subject: Re: [xsl] Adding Missing Elements
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Tue, 13 Sep 2005 21:48:36 +0200

Tempore 18:01:35, die 09/13/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Emerson, Matt <Matt.Emerson@xxxxxxx>:

Given these possible variations and based on some processing elsewhere
in the document, I would like to make sure that <node> always has
<item>B</item> in its list...possibly adding <list> if it is not

Can someone give me some suggestions on the best way to do this?
"The best way to do this" does not exist, it's amatter of personal personal style.

Here's a solution that I perceive as most elegant:

<xsl:stylesheet version="1.0" xmlns:var="myvar"
<xsl:output method="xml" indent="yes"/>


<xsl:variable name="var" select="document('')/xsl:stylesheet/var:root/*"/>

<xsl:template match="node()|@*">
		<xsl:apply-templates select="node()|@*" />

<xsl:template match="node|list|item">
	<xsl:element name="{local-name()}">
		<xsl:apply-templates select="@*" />
		<xsl:apply-templates select="
			node()" />


Joris Gillis (
B+Et ipsa scientia potestas estB;  - Francis Bacon , Meditationes sacrae

Current Thread