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>
Use:
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:Memberandam:Members— this is probably a typing error.Correcting the above , so that there are only
am:Members, the XML document becomes:The XPath expression becomes:
And, for the convenience of the OP, here is a complete transformation that copies exactly the wanted nodes:
When this transformation is applied on the above XML document, the wanted, correct result is produced: