Altova Mailing List Archives

[xsl] [XSLT 2.0] Using insert-before() to insert a non-atomic value

From: "Roger L. Costello" <costello@--------->
Date: 2/27/2004 12:14:00 PM
Hi Folks,

I have two questions regarding using the insert-before function to
insert a node into a sequence of nodes: 

Consider this XML document:

<?xml version="1.0"?>
        <Member level="platinum">
        <Member level="gold">
        <Member level="platinum">

Here I create a variable to hold the sequence of Members:

<xsl:variable name="members" select="/FitnessCenter/Member"/>

Here I iterate through the Members and print out their Names:

<xsl:for-each select="$members">
       <xsl:value-of select="Name"/>
       <xsl:text> </xsl:text>

Output: Jeff David Roger

Now I would like to insert into the member sequence a new member.  Here
I create a variable containing the new member:

<xsl:variable name="new-member">
    <Member level="platinum">

Question #1: Is this the correct approach to creating a new Member?  I
suspect not, but I don't know how else to do it.

Now, using the insert-before function, I would like to insert this new
member before the second Member:

<xsl:variable name="members-plus-new-member"

Lastly, I would like to print the Name of each Member in the new

<xsl:for-each select="$members-plus-new-member">
       <xsl:value-of select="Name"/>
       <xsl:text> </xsl:text>

The output that I get is not what I desire:

Output: Jeff David Roger

Note that Sally is missing.

Question #2: What am I doing wrong?  Obviously, I am not understanding
something fundamental about sequences in XSLT 2.0.  Any clarity on this
topic would be greatly appreciated.  /Roger

 XSL-List info and archive:


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.