Hi, I wonder if you could help. I am a beginner! I have an xml file structured like this:

Code:
<?xml version="1.0" encoding="utf-8"?>
<Zthes>
 <term>
    <termId>MESH002084</termId>
    <termUpdate>Add</termUpdate>
    <termName>Asthma</termName>
    <termType>Pt</termType>
   [...] a load more attributes 
    <relation>
      <relationType>NT</relationType>
      <termId>MANUAL000031</termId>
      <termName>Exercise-Induced Asthma</termName>
    </relation>
    <relation>
      <relationType>NT</relationType>
      <termId>MESH023026</termId>
      <termName>Status Asthmaticus</termName>
    </relation>
    <relation>
      <relationType>RT</relationType>
      <termId>MESH003628</termId>
      <termName>Bronchitis</termName>
    </relation>
  </term>
  <term>
    <termId>NESH002084</termId>
    <termUpdate>Add</termUpdate>
    <termName>Term 2</termName>
    <termType>Pt</termType>
   [...] a load more attributes 
    <relation>
      <relationType>NT</relationType>
      <termId>Not M</termId>
      <termName>term 3</termName>
    </relation>
  </term>
  </Zthes>
What I am trying to do is use xsl to to through, do a match on <term>
<termId>MESH002084</termId>


If it is not a MeSH Term, ignore it.

If it is a MeSH term, has <termType>Pt</termType>, and a <relation> tag exists (not all terms have relation), then what I would like to do is to copy any NT relations, so:
Code:
<relationType>NT</relationType>
      <termId>MESH023026</termId>
      <termName>Status Asthmaticus</termName>
    </relation>
And duplicate this but with a new <relationType>NT_mesh</relationType>:

Code:
<relationType>NT</relationType>
      <termId>MESH023026</termId>
      <termName>Status Asthmaticus</termName>
    </relation>
    <relationType>NT_mesh</relationType>
      <termId>MESH023026</termId>
      <termName>Status Asthmaticus</termName>
    </relation>
All I have got so far is hopeless, has anyone got any advice (aside from give up LOL)