How can I use XSLT to find the direct descendants of a given element with a 
given name?

I want to create a tab-delimited version of an XML file. I have the following 
XML snippet, and notice how each of the persons in the first presentation have 
a single affiliation, but the person of the second presentation has two 
affiliations:

  <session>
    <presentation>
      <person>RICHARD G. ANDERSON</person>
      <affiliation>Lindenwood University</affiliation>
      <person>AREERAT KICHKHA</person>
      <affiliation>Lindenwood University</affiliation>
      <paper>Is Less More?</paper>
    </presentation>
    <presentation>
      <person>BRIAN W. SLOBODA</person>
      <affiliation>University of Maryland</affiliation>
      <affiliation>University College</affiliation>
      <paper>Inflation Policies</paper>
    </presentation>
  </session>

I want my resulting tab-delimited file to look like this:

  RICHARD G. ANDERSON  Lindenwood University                      Is Less More?
  AREERAT KICHKHA      Lindenwood University                      Is Less More?
  BRIAN W. SLOBODA     University of Maryland|University College  Inflation 
Policies

I have the following XSLT snippet, but my process of getting affiliations is 
not nearly correct:

  <xsl:for-each select=".//presentation">
    <xsl:for-each select=".//person">
      <xsl:value-of select="normalize-space(.)"/><xsl:text>&#09;</xsl:text>
      <xsl:value-of 
select="normalize-space(../affiliation)"/><xsl:text>&#09;</xsl:text>
      <xsl:value-of 
select="normalize-space(../paper)"/><xsl:text>&#10;</xsl:text>
    </xsl:for-each>
  </xsl:for-each>

Can you offer any suggestions? What sort of XPath expression should I be using 
to find all of the affiliation elements between person elements? Something with 
following-sibling? 

Reply via email to