title: updating an xml from another one using ids
body: <p>I have to pick text from <code>translation.xml</code> and update <code>skeleton.xml</code>'s respective (where <code>@xid</code> =<code>@id</code>) nodes . in other words IF <code>@id</code> of <code>translation.xml</code> matches with <code>@xid</code> of <code>skeleton.xml</code>, the text content should be placed under <code>skeleton.xml</code> (+ if there is child element present the text content (inline element <code>i</code>, <code>b</code>, etc) also should go in respective parent element: Please see example below for more details:</p>
  
  <p>Note: the inline element could be anything in skeleton.xml (its not restrict to b or i, so it should be generic)</p>
  
  <p><em>skeleton.xml</em></p>
  
  <pre><code>    &lt;root&gt;
          &lt;para a="b" b="c"&gt;
              &lt;text xid="1"&gt;This is first para &lt;b xid="2" a="c" b="d"&gt;This is bold &lt;i xid="3" b="d" c="e"&gt;This is italics&lt;/i&gt; rest of bold&lt;/b&gt; rest of para&lt;/text&gt;
          &lt;/para&gt;
          &lt;para&gt;&lt;text xid="4"&gt;This is second para&lt;/text&gt;&lt;/para&gt;
          &lt;para&gt;&lt;text xid="5"&gt;This is unchanged para&lt;/text&gt;&lt;/para&gt;
          &lt;para&gt;&lt;text xid="6"&gt;This is unchanged para&lt;/text&gt;&lt;/para&gt;
      &lt;/root&gt;
  </code></pre>
  
  <p><em>translation.xml</em></p>
  
  <pre><code>    &lt;root&gt;
          &lt;TU id="1"&gt;
              &lt;source&gt;This is first para &lt;g id="2" tagName="b"&gt;This is bold &lt;g id="3" tagName="i"&gt;This is italics&lt;/g&gt; rest of bold&lt;/g&gt; rest of para&lt;/source&gt;
              &lt;target&gt;suum primum para &lt;g id="2" tagName="b"&gt;Et hoc confidens, &lt;g id="3" tagName="i"&gt;Hoc est, Te Deum&lt;/g&gt; Reliqua autem audet,&lt;/g&gt; reliqua autem verba haec&lt;/target&gt;
          &lt;/TU&gt;
          &lt;TU id="4"&gt;
              &lt;source&gt;This is second para&lt;/source&gt;
              &lt;target&gt;Hoc est secundum verba haec&lt;/target&gt;
          &lt;/TU&gt;
      &lt;/root&gt;
  </code></pre>
  
  <p><em>UpdatedSkeleton.xml</em></p>
  
  <pre><code>    &lt;root&gt;
          &lt;para a="b" b="c"&gt;
              &lt;text xid="1"&gt;suum primum para &lt;b xid="2" a="c" b="d"&gt;Et hoc confidens, &lt;i xid="3" b="d" c="e"&gt;Hoc est, Te Deum&lt;/i&gt; Reliqua autem audet,&lt;/b&gt; reliqua autem verba haec&lt;/text&gt;
          &lt;/para&gt;
          &lt;para&gt;&lt;text xid="4"&gt;Hoc est secundum verba haec&lt;/text&gt;&lt;/para&gt;
          &lt;para&gt;&lt;text xid="5"&gt;This is unchanged para&lt;/text&gt;&lt;/para&gt;
          &lt;para&gt;&lt;text xid="6"&gt;This is unchanged para&lt;/text&gt;&lt;/para&gt;
      &lt;/root&gt;
  </code></pre>
  
  <p>I am trying with this code, but facing challenge to place text of inline content at the right place:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          version="2.0"&gt;
          &lt;xsl:param name="translation" select="'file:/C:/Skeleton.xml'"&gt;&lt;/xsl:param&gt;
          &lt;xsl:variable name="doc"&gt;
              &lt;xsl:copy-of select="doc($translation)"/&gt;
          &lt;/xsl:variable&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="text"&gt;
              &lt;xsl:variable name="skelID" select="@xid"/&gt;
              &lt;xsl:choose&gt;
                  &lt;xsl:when test="$doc//*[$skelID=@id]"&gt;                
                      &lt;xsl:apply-templates select="$doc//*[$skelID=@id]/target"/&gt;
                  &lt;/xsl:when&gt;
                  &lt;xsl:otherwise&gt;
                      &lt;xsl:apply-templates/&gt;
                  &lt;/xsl:otherwise&gt;
              &lt;/xsl:choose&gt;
          &lt;/xsl:template&gt;
      &lt;/xsl:stylesheet&gt;
  </code></pre>