Yay. Accounting :|
I've got a set of accounting entries; they come in pairs -- 1 debit & 1 credit.  The two entries share the same <SequenceID>.  I want both entries if either of the entries references account 1111.
The (non-working) query I'm using (which I loosely based on [XPath. Select nodes based on an other, related node) is:
GLPostings/GLTransaction[GLPostings/GLTransaction[AccountCode = '1111']/SequenceID = SequenceID]
but I'm getting "empty sequence returned".
If I test part of the query: GLPostings/GLTransaction[AccountCode = '1111']/SequenceID I get multiple SequenceIDs as expected.  So... how do I turn those multiple SequenceIDs into the set of nodes I'm after?
Here's some test data:
<?xml version="1.0" encoding="UTF-8"?>
<GLPostings>
   <GLTransaction RowNumber="1">
      <CRDR>Dr</CRDR>
      <SequenceID>616</SequenceID>
      <AccountCode>5531</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="2">
      <CRDR>Cr</CRDR>
      <SequenceID>616</SequenceID>
      <AccountCode>2118</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="3">
      <CRDR>Dr</CRDR>
      <SequenceID>617</SequenceID>
      <AccountCode>1111</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="4">
      <CRDR>Cr</CRDR>
      <SequenceID>617</SequenceID>
      <AccountCode>1234</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="5">
      <CRDR>Dr</CRDR>
      <SequenceID>618</SequenceID>
      <AccountCode>1231</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="6">
      <CRDR>Cr</CRDR>
      <SequenceID>618</SequenceID>
      <AccountCode>1231</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="7">
      <CRDR>Dr</CRDR>
      <SequenceID>619</SequenceID>
      <AccountCode>2341</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="8">
      <CRDR>Cr</CRDR>
      <SequenceID>619</SequenceID>
      <AccountCode>1111</AccountCode>
   </GLTransaction>
</GLPostings>
What I'd like to get back is:
   <GLTransaction RowNumber="3">
      <CRDR>Dr</CRDR>
      <SequenceID>617</SequenceID>
      <AccountCode>1111</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="4">
      <CRDR>Cr</CRDR>
      <SequenceID>617</SequenceID>
      <AccountCode>1234</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="7">
      <CRDR>Dr</CRDR>
      <SequenceID>619</SequenceID>
      <AccountCode>2341</AccountCode>
   </GLTransaction>
   <GLTransaction RowNumber="8">
      <CRDR>Cr</CRDR>
      <SequenceID>619</SequenceID>
      <AccountCode>1111</AccountCode>
   </GLTransaction>
Any hints greatly appreciated.
EDIT: I can solve the problem so:
<xsl:for-each select="/GLPostings/GLTransaction[AccountCode = 1111']/SequenceID">
    <xsl:variable name="Seq" select="."/>
    <xsl:for-each select="/GLPostings/GLTransaction[SequenceID = $Seq]">
         <xsl:call-template name="output-row">
        </xsl:call-template>
    </xsl:for-each>          
</xsl:for-each>  
But it seems kind of... dirty.