Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:56:24+00:00 2026-06-11T17:56:24+00:00

XML/XSLT Newbie here. I have some sets of data that need to be compared.

  • 0

XML/XSLT Newbie here.
I have some sets of data that need to be compared. The output needs to be a list of Previous Members of a Roster that are not in the current Roster. The Node contains both sets of elements and I need to cycle through and put the missing member into a csv file.
In the example below, Kerry Smith is listed a ‘Previous_Members’ but not ‘Member’, so she needs to be listed in the output.

This same structure will occur for multiple teams. And there can be different #’s on Different Teams. (Team Smith may have 4 members, Team Jones may have 7 members, Team Jackson may have 10, etc.) So the solution needs to be able to handle a variable number of elements.

This is a big stretch for me experience-wise, so any guidance would be appreciated.

<?xml version="1.0" encoding="UTF-8"?>
<am:Team>
<am:First_Day>08/24/2012</am:First_Day>
<am:_Date>08/23/2012</am:_Date>
<am:Member am:Descriptor="Clare Smith">
    <am:ID am:type="Member_ID">4588-D4</am:ID>
</am:Member>
<am:Members am:Descriptor="Jack Smith">
    <am:ID am:type="Member_ID">4588-D3</am:ID>
</am:Members>
<am:Members am:Descriptor="Colin Smith">
    <am:ID am:type="Member_ID">4588-D2</am:ID>
</am:Members>
<am:Previous_Members am:Descriptor="Kerry Smith">
    <am:ID am:type="Member_ID">4588-D1</am:ID>
</am:Previous_Members>
<am:Previous_Members am:Descriptor="Colin Smith">
    <am:ID am:type="Member_ID">4588-D2</am:ID>
</am:Previous_Members>
<am:Previous_Members am:Descriptor="Jack Smith">
    <am:ID am:type="Member_ID">4588-D3</am:ID>
</am:Previous_Members>
<am:Previous_Members am:Descriptor="Clare Smith">
    <am:ID am:type="Member_ID">4588-D4</am:ID>
</am:Previous_Members>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:56:25+00:00Added an answer on June 11, 2026 at 5:56 pm

    Use:

    /*/am:Previous_Members[not(am:ID=/*/am:Member/am:ID)]
    

    This selects all previous team members whose ID isn’t an ID of a current member.

    Apply templates only to the elements selected by this XPath expression.

    Update:

    The XML document as provided contains both: am:Member and am:Members — this is probably a typing error.

    Correcting the above , so that there are only am:Members, the XML document becomes:

    <am:Team xmlns:am="some:am">
        <am:First_Day>08/24/2012</am:First_Day>
        <am:_Date>08/23/2012</am:_Date>
        <am:Members am:Descriptor="Clare Smith">
            <am:ID am:type="Member_ID">4588-D4</am:ID>
        </am:Members>
        <am:Members am:Descriptor="Jack Smith">
            <am:ID am:type="Member_ID">4588-D3</am:ID>
        </am:Members>
        <am:Members am:Descriptor="Colin Smith">
            <am:ID am:type="Member_ID">4588-D2</am:ID>
        </am:Members>
        <am:Previous_Members am:Descriptor="Kerry Smith">
            <am:ID am:type="Member_ID">4588-D1</am:ID>
        </am:Previous_Members>
        <am:Previous_Members am:Descriptor="Colin Smith">
            <am:ID am:type="Member_ID">4588-D2</am:ID>
        </am:Previous_Members>
        <am:Previous_Members am:Descriptor="Jack Smith">
            <am:ID am:type="Member_ID">4588-D3</am:ID>
        </am:Previous_Members>
        <am:Previous_Members am:Descriptor="Clare Smith">
            <am:ID am:type="Member_ID">4588-D4</am:ID>
        </am:Previous_Members>
    </am:Team>
    

    The XPath expression becomes:

    /*/am:Previous_Members[not(am:ID=/*/am:Members/am:ID)]
    

    And, for the convenience of the OP, here is a complete transformation that copies exactly the wanted nodes:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:am="some:am" exclude-result-prefixes="am">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="am:Team/*"/>
    
     <xsl:template match="am:Previous_Members[not(am:ID=/*/am:Members/am:ID)] ">
         <xsl:copy-of select="."/>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the above XML document, the wanted, correct result is produced:

    <am:Previous_Members xmlns:am="some:am" am:Descriptor="Kerry Smith">
       <am:ID am:type="Member_ID">4588-D1</am:ID>
    </am:Previous_Members>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often see people asking XML/XSLT related questions here that root in the inability
So currently I'm doing some XML-> XSLT-> (HTML5/CSS3) work. Right now I have a
I need to transform XML using xslt. i want to transform a node that
An XSLT-newbie problem: I need to substitute a text value in XML-file. All other
I'm very new to XML and XSLT. I have a homework assignment that asks
I've made an XSLT application that transforms XML data into a form, that when
I have a bunch of ancillary XML and XSLT files that I want to
I have a listview that loads dynamic controls from xml/xslt <asp:ListView ID=DynamicFields runat=server DataSourceID=CustomFields
I have written a small application in HTML/CSS/JQuery/XML/XSLT that ends up writing to an
I have written a C# code for triggering an XML to XML (XSLT) transformation.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.