Hi all:
I'm having trouble inserting a block of text when a certain condition is met into an xml document using XSLT. Suppose I have the following xml:
<oldStep Name="Step1">
    <oldItems>
        <oldItem ItemName="item1">
        </oldItem>
        <!-- want to add an extra <Item> here if Step Name == "Step1" -->
        <oldItem ItemName="Step1item">
        </oldItem>
    </oldItems>
</oldStep>
<oldStep Name="Step2">
    <oldItems>
       ...
    </oldItems>
</oldStep>
Amongst the conversion of the old node names into new ones, I want to add an extra block of text (or a manually constructed node) whenever oldStep Name is equal to a certain value (in this case, Step1). I tried using the following XSLT, but it ended up with a weird behaviour in adding the block of text to every single node (sometimes even not under a node) in the xml once its matched. Also, I'm having trouble skipping the node so the node can be inserted within Items, not directly under oldStep:
<xsl:template match="oldItems">
    <xsl:element name="Item">
        <xsl:if test="../@Name = 'Step1'>
            <xsl:call-template name = "identity"></xsl:call-template>
        </xsl:if>
        <xsl:apply-templates />
    </xsl:element>
</xsl:template>
<xsl:template match="node()" name="identity">
    <xsl:element name="Item">
        <xsl:attribute name="ItemName">Step1item</xsl:attribute>
        </xsl:apply-templates />
    </xsl:element>
</xsl:template>
I get the feeling that I've gotten the conditions wrong, but googling didn't really help (search string too vague). What am I missing in the xsl? Or, is there a better approach to this problem?
Thanks.