RE: [xsl] Value-of varible question

Subject: RE: [xsl] Value-of varible question
From: "Hansen, John" <John.Hansen@xxxxxxxxxx>
Date: Fri, 16 Apr 2004 14:28:32 -0700
The problem with John Hamman's original code

<xsl:param name="local" select="'en-EN'"/>
<xsl:template match="Title">
	<Title>
		<xsl:copy-of
select="/iThink.ePulp/Page/Content/Meta/Title[@lang=$local]"/>
	</Title>
</xsl:template>

is that the select of the xsl:copy-of isn't relative to the current node
matched by the xsl:template match="Title" element.  But as written even
if the copy-of was relative he would get output like

<Title>
<Title lang="en-US">Williamsburg Web Design</Title>
</Title>

since copy-of will copy the selected nodes (which are the Title elements
having a lang attribute with the value of $local).  As written, with the
non-relative select on the copy-of, the code executes something like
this:

for each Title found in the document (relative to the current node) 
  insert into the output stream a Title element containing
    a copy of every Title element at the specified nesting level with a
lang attribute equal to $local

John Hansen

Current Thread