I wish to filter records during an xsl transformation. I know basic filtering is quite simple, however, I wish it to be conditional based on data from the original source xml data.
My source data will have several updates for the same record in it. Each update will be identified with an event sequence number. I only want the last event sequence in my transformed data.
Here is a sample of my source data:
<?xml version="1.0" encoding="UTF-8"?>
<Msg xmlns="http://schemas.namespace.org/myschema/myschame.xsd" schemalocation="http://schemas.namespace.org/myschema/myschema.xsd ../myschema.xsd" schemaversion="5">
<NumberofRecordsEnclosed>7</NumberofRecordsEnclosed>
<Record>
<EventSequenceNumber>3</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>1234</Number>
</Id>
</ReplaceRecord>
</Record>
<Record>
<EventSequenceNumber>4</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>1234</Number>
</Id>
</ReplaceRecord>
</Record>
<Record>
<EventSequenceNumber>5</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>1234</Number>
</Id>
</ReplaceRecord>
</Record>
<Record>
<EventSequenceNumber>6</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>1234</Number>
</Id>
</ReplaceRecord>
</Record>
<Record>
<EventSequenceNumber>1</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>5678</Number>
</Id>
</ReplaceRecord>
</Record>
<Record>
<EventSequenceNumber>2</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>5678</Number>
</Id>
</ReplaceRecord>
</Record>
<Record>
<EventSequenceNumber>7</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>1234</Number>
</Id>
</ReplaceRecord>
</Record>
</Msg>
When I transform the document, I only want the following records:
<?xml version="1.0" encoding="UTF-8"?>
<Msg xmlns="http://schemas.namespace.org/myschema/myschame.xsd" schemalocation="http://schemas.namespace.org/myschema/myschema.xsd ../myschema.xsd" schemaversion="5">
<NumberofRecordsEnclosed>7</NumberofRecordsEnclosed>
<Record>
<EventSequenceNumber>2</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>5678</Number>
</Id>
</ReplaceRecord>
</Record>
<Record>
<EventSequenceNumber>7</EventSequenceNumber>
<ReplaceRecord>
<Id>
<Number>1234</Number>
</Id>
</ReplaceRecord>
</Record>
</Msg>
As you can see, there are only two records that I care about: Where 'EventSequenceNumber' is 7 for 'Number' 1234
Where 'EventSequenceNumber' is 2 for 'Number' 5678
The 'EventSequenceNumber' data is a true sequence number. If I receive another XML source data that contains 'Number' 1234, the 'EventSequenceNumber' will continue from 8 onwards.
Is this possible with XSL?
Could somenody please assist in logic to go from the above source & result?
Thankyou.