xsl-list
[Top] [All Lists]

RE: Value-of varible question

2004-04-16 14:28:32
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[(_at_)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


<Prev in Thread] Current Thread [Next in Thread>