title: Transform XML with XSL that calls another XML document
body: <p>I am trying to dynamically add a list of Employee IDs into one XML document from another XML document. Essentially I am trying to build an XML query and insert the list of Employees from another XML results document.</p>
  
  <p>This is the EmployeeList.xml that is being called by the XSL: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ExportTXML xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07" xmlns:ns1="http://www.taleo.com/ws/integration/toolkit/2005/07" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:e="http://www.taleo.com/ws/so800/2009/01" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;e:User&gt;
          &lt;e:EmployeeID&gt;0000000123&lt;/e:EmployeeID&gt;
          &lt;e:SystemUser&gt;false&lt;/e:SystemUser&gt;
      &lt;/e:User&gt;
      &lt;e:User&gt;
          &lt;e:EmployeeID&gt;0000000224&lt;/e:EmployeeID&gt;
          &lt;e:SystemUser&gt;false&lt;/e:SystemUser&gt;
      &lt;/e:User&gt;
  &lt;/ExportTXML&gt;
  </code></pre>
  
  <p>This is the XML that is being transformed:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;quer:query productCode="SO1015" model="http://www.taleo.com/ws/so800/2009/01" projectedClass="User" locale="en" mode="T-XML" largegraph="true" preventDuplicates="false" xmlns:quer="http://www.taleo.com/ws/integration/query"&gt;&lt;quer:subQueries/&gt;&lt;quer:projections&gt;&lt;quer:projection&gt;&lt;quer:field path="EmployeeID"/&gt;&lt;/quer:projection&gt;&lt;/quer:projections&gt;&lt;quer:projectionFilterings/&gt;&lt;quer:filterings&gt;&lt;quer:filtering&gt;
    &lt;quer:includedIn&gt;
      &lt;quer:field path="EmployeeID"/&gt;
      &lt;quer:list&gt;
        &lt;!--List will be filled at runtime.--&gt;
      &lt;/quer:list&gt;
    &lt;/quer:includedIn&gt;
  &lt;/quer:filtering&gt;&lt;/quer:filterings&gt;&lt;quer:sortings/&gt;&lt;quer:sortingFilterings/&gt;&lt;quer:groupings/&gt;&lt;quer:joinings/&gt;&lt;/quer:query&gt;
  </code></pre>
  
  <p>And below is the XSL to transform the XMl and call the EmployeeList.xml:</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" xmlns:quer="http://www.taleo.com/ws/integration/query" xmlns:e="http://www.taleo.com/ws/so800/2009/01" exclude-result-prefixes="e"&gt;
      &lt;xsl:output method="xml" encoding="UTF-8" indent="yes"/&gt;
      &lt;xsl:param name="EMPLOYEE_FILTER"&gt;C:\temp\EmployeeList.xml&lt;/xsl:param&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 match="/quer:query/quer:filterings/quer:filtering/quer:includedIn[quer:field[@path='EmployeeID']]/quer:list"&gt;
          &lt;xsl:copy&gt;
              &lt;xsl:for-each select="document(replace($EMPLOYEE_FILTER, '\\', '/'))//e:User/e:EmployeeID"&gt;
                  &lt;quer:string&gt;
                      &lt;xsl:value-of select="."/&gt;
                  &lt;/quer:string&gt;
              &lt;/xsl:for-each&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The output should look like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;quer:query productCode="SO1015" model="http://www.taleo.com/ws/so800/2009/01" projectedClass="User" locale="en" mode="T-XML" largegraph="true" preventDuplicates="false" xmlns:quer="http://www.taleo.com/ws/integration/query"&gt;&lt;quer:subQueries/&gt;&lt;quer:projections&gt;&lt;quer:projection&gt;&lt;quer:field path="EmployeeID"/&gt;&lt;/quer:projection&gt;&lt;/quer:projections&gt;&lt;quer:projectionFilterings/&gt;&lt;quer:filterings&gt;&lt;quer:filtering&gt;
    &lt;quer:includedIn&gt;
      &lt;quer:field path="EmployeeID"/&gt;
      &lt;quer:list&gt;
          &lt;quer:string&gt;0000000123&lt;/quer:string&gt;
          &lt;quer:string&gt;0000000224&lt;/quer:string&gt;
      &lt;/quer:list&gt;
    &lt;/quer:includedIn&gt;
  &lt;/quer:filtering&gt;&lt;/quer:filterings&gt;&lt;quer:sortings/&gt;&lt;quer:sortingFilterings/&gt;&lt;quer:groupings/&gt;&lt;quer:joinings/&gt;&lt;/quer:query&gt;
  </code></pre>