title: XSLT - Modify values of Element siblings based on condition
body: <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;schools&gt;
  &lt;city&gt;Marshall&lt;/city&gt;
  &lt;state&gt;Maryland&lt;/state&gt;
  &lt;highschool&gt;
  &lt;schoolname&gt;Marshalls&lt;/schoolname&gt;
  &lt;department id="1"&gt;
    &lt;deptCode&gt;D1&lt;/deptCode&gt;
    &lt;deptName&gt;Chemistry&lt;/deptName&gt;
    &lt;deptHead&gt;Henry Carl&lt;/deptHead&gt;
  &lt;/department&gt;
  &lt;department id="2"&gt;
    &lt;deptCode&gt;D2&lt;/deptCode&gt;
    &lt;deptName&gt;Science-Physics&lt;/deptName&gt;
    &lt;deptHead&gt;Martin Sean&lt;/deptHead&gt;
  &lt;/department&gt;
  &lt;department id="3"&gt;
    &lt;deptCode&gt;D3&lt;/deptCode&gt;
    &lt;deptName&gt;Science-Botany&lt;/deptName&gt;
    &lt;deptHead&gt;Susanne Charles&lt;/deptHead&gt;
  &lt;/department&gt;
  &lt;department id="4"&gt;
    &lt;deptCode&gt;D4&lt;/deptCode&gt;
    &lt;deptName&gt;Science-Chemistry&lt;/deptName&gt;
    &lt;deptHead&gt;Henry Carl&lt;/deptHead&gt;
  &lt;/department&gt;
  &lt;highschool&gt;
  &lt;schools&gt;
  </code></pre>
  
  <p>From the above xml, if city is Marshal and school name is Marshalls, then check if both dept names Chemistry and Science-Chemistry exists, 
     if true, remove the department element of Chemistry. If Science-Chemistry does not exist, then modify the Chemistry department values with 
     DeptCode as 4 and Dept Name as Science-Chemistry and Department attribute id as 4.</p>
  
  <p>Below is the XSLT I am using. I need to write the code under remDept template to remove the Dept if dept name Science Chemistry exists. 
     And modify the Dept Code and Dept Name to D4 in template modifyDept if Science Chemistry does not exist. Can someone help me? Thanks in advance</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" indent="yes" /&gt;
  &lt;xsl:strip-space elements="*" /&gt;
  
  &lt;xsl:template match="node()!@*"&gt;
    &lt;xsl:copy&gt;
       &lt;xsl:apply-templates select="node()|@*"/&gt;
    &lt;xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="/schools[city='Marshall' and /highschools/schoolname='Marshalls']"&gt;
     &lt;xsl:if test="contains(deptName='Science-Chemistry')"&gt;
        &lt;xsl:choose&gt;
           &lt;xsl:when test="contains(deptName='Chemistry'"&gt;
              &lt;xsl:call-template name="remDept"&gt;
           &lt;/xsl:when&gt;
           &lt;xsl:otherwise&gt;
               &lt;xsl:call-template name="modifyDept"&gt;
           &lt;/xsl:otherwise&gt;
        &lt;/xsl:choose&gt;
     &lt;/xsl:if&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="remDept"&gt;
  // TO DO
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="modifyDept"&gt;
  // TO DO
  &lt;/xsl:template&gt;
  
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>