title: xquery multi if-else statement
body: <p>Using xPath, I'm getting data from html field, this data can be in this format (including parentheses):</p>
  
  <blockquote>
    <h2>DATA |||| symbols i'm using to explain my code</h2>
    
    <p>(bornPlace, bornDate-DeathDate) |||| (str, A-B) = note that str may also contain '-'</p>
    
    <p>(bornPlace, bornDate) |||| (str, A)</p>
    
    <p>(bornPlace) |||| (str)</p>
    
    <p>(bornDate-DeathDate) |||| (A-B)</p>
    
    <p>(bornDate) |||| (A)</p>
    
    <p>Or completely empty</p>
  </blockquote>
  
  <p>I'm trying to retrieve each element into separate variable using multiple if-else statements, but it seems that it doesnt like multi-line commands (I think so).</p>
  
  <p>I already made a code wich is not working :-/ (it says expecting return, found else if ....)</p>
  
  <pre><code>let $temp1 := data(normalize-space(substring-before(substring-after(//div/div[2]/h2/text(), '('), ')')))
  
  if (contains($temp1,','))           (:   (str, A-B) or (str, A)   :)
  then
      let $bornPlace := substring-before($temp1, ',')
      let $temp2 := substring-after($temp1, ',')
  
      if (contains($temp2,'-'))
      then
          let $bornDate := substring-before($temp2, '-')
          let $deathDate := substring-after($temp2, '-')
      else
          let $bornDate := $temp2
          let $deathDate := data('')
  
  else if (contains($temp1,'-'))
      then                            (:   (s-t-r) or (A-B)   :)
          let $temp2 := normalize-space(substring-before($temp1, '-'))
          if (number($temp2)=$temp2)     (: it's a number :)
          then
              let $bornDate := temp2
              let $deathDate := normalize-space(substring-after($temp2, '-'))
              let $bornPlace := data('')
          else
              let $bornPlace := $temp1
              let $bornDate := data('')
              let $deathDate := data('')
      else                            (:   (str) or (A)   :)
          if (number($temp1)=$temp1)     (: it's a number :)
          then
              let $bornDate := temp1
              let $deathDate := data('')
              let $bornPlace := data('')
          else
              let $bornPlace := $temp1
              let $bornDate := data('')
              let $deathDate := data('')
  </code></pre>
  
  <p>Also if there's a more beautiful way to do that, i'll take it :D</p>
  
  <p>Thanks in advance for your help :)</p>