<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    You're very dependent on the query optimizer for this. It all
    depends which XQuery engine you are using. The commercial edition of
    Saxon, for example (Saxon-EE) will do a much better job on it than
    the home edition (Saxon-HE).<br>
    <br>
    Michael Kay<br>
    Saxonica<br>
    <br>
    On 06/04/2011 12:37, Kunal Chauhan wrote:
    <blockquote
      cite="mid:BANLkTinTR46V5F=KAUbtxvTwJFTzAwUkAg@mail.gmail.com"
      type="cite">
      <div>Hi All,</div>
      <div>&nbsp;</div>
      <div>I wrote one XQuery it's work but taking time I want to
        optimize time taken by that XQuery.</div>
      <div>Here I explaine a brief scenario.</div>
      <div>There are two diff xml files. I need to check first xml
        file's tag's attributes value and check it into second file</div>
      <div>If this value is same than I need to go forward for more
        process.</div>
      <div>I used for loop for it but it takes time so how can I
        optimize time in this case.</div>
      <div>&nbsp;</div>
      <div>here is example</div>
      <div>&nbsp;</div>
      <div><strong><font size="4">First XML file</font></strong></div>
      <div>&nbsp;</div>
      <div>&lt;?xml version="1.0" encoding="US-ASCII"?&gt;<br>
        &lt;doc1&gt;<br>
        &lt;info id="1"&gt;<br>
        &lt;fname&gt;Kunal&lt;/fname&gt;<br>
        &lt;lname&gt;chauhan&lt;/lname&gt;<br>
        &lt;/info&gt;<br>
        &lt;info id="2"&gt;<br>
        &lt;fname&gt;Bhavik&lt;/fname&gt;<br>
        &lt;lname&gt;Solanki&lt;/lname&gt;<br>
        &lt;/info&gt;<br>
        &lt;info id="3"&gt;<br>
        &lt;fname&gt;Geet&lt;/fname&gt;<br>
        &lt;lname&gt;Gangwar&lt;/lname&gt;<br>
        &lt;/info&gt;<br>
        &lt;/doc1&gt;</div>
      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div><strong><font size="4">Second XML file</font></strong></div>
      <div>&nbsp;</div>
      <div>&lt;?xml version="1.0" encoding="US-ASCII"?&gt;<br>
        &lt;Doc2&gt;<br>
        &lt;empinfo id="1"&gt;<br>
        &lt;name&gt;Kunal&lt;/name&gt;<br>
        &lt;dept&gt;tech&lt;/dept&gt;<br>
        &lt;roll&gt;prog&lt;/roll&gt;<br>
        &lt;/empinfo&gt;<br>
        &lt;empinfo id="2"&gt;<br>
        &lt;name&gt;Bhavik&lt;/name&gt;<br>
        &lt;dept&gt;tech&lt;/dept&gt;<br>
        &lt;roll&gt;prog&lt;/roll&gt;<br>
        &lt;/empinfo&gt;<br>
        &lt;empinfo id="3"&gt;<br>
        &lt;name&gt;Geet&lt;/name&gt;<br>
        &lt;dept&gt;tech&lt;/dept&gt;<br>
        &lt;roll&gt;tl&lt;/roll&gt;<br>
        &lt;/empinfo&gt;<br>
        &lt;/Doc2&gt;</div>
      <div>&nbsp;</div>
      <div><strong><font size="4">XQuery</font></strong></div>
      <div>&nbsp;</div>
      <div><span class="c9Y6TC"><font color="#0000ff">let</font></span>
        $d1 <span class="c50HZ4"><font color="#008080">:=</font></span>
        doc(<span class="c4ZSSG"><font color="#800080">"D:/xbrl/NewDoc1.xml"</font></span>)<br>
        <span class="c9Y6TC"><font color="#0000ff">let</font></span> $d2
        <span class="c50HZ4"><font color="#008080">:=</font></span> doc(<span
          class="c4ZSSG"><font color="#800080">"D:/xbrl/NewDoc2.xml"</font></span>)<br>
        <br>
        <span class="c9Y6TC"><font color="#0000ff">for</font></span> $x
        <span class="c9Y6TC"><font color="#0000ff">in</font></span>
        $d1,$y <span class="c9Y6TC"><font color="#0000ff">in</font></span>
        $d2<br>
        <font color="#0000ff">check</font>&nbsp;($x/doc1/info/@id <span
          class="c50HZ4"><font color="#008080">=</font></span>
        $y/Doc2/empinfo/<span class="c9Y6TC"><font color="#0000ff">attribute::</font></span>id)&nbsp;&nbsp;
        // check ids of each node and if they are same than process
        forward</div>
      <div>...</div>
      <div>...</div>
      <div>..<br>
        <span class="c9Y6TC"><font color="#0000ff">return</font></span>
        $y/Doc2/empinfo/name </div>
      <div>&nbsp;</div>
      <div>in this example I just return name but actualyy if ids are
        same than I need to go forward and do some more process and
        after that return final result.</div>
      <div>so is there any other way, other than for loop</div>
      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <div>Thanks &amp; Regards,<br clear="all">
        <br>
      </div>
      <div style="text-align: left;"><font color="#9999ff"><strong>Kunal
            Chauhan</strong></font></div>
      <div style="text-align: left;"><a moz-do-not-send="true"
          href="mailto:mail4ck@gmail.com" target="_blank"><font
            color="#9999ff">mail4ck@gmail.com</font></a></div>
      <div style="text-align: left;"><font color="#9999ff">[+918655517141]</font></div>
      <div style="text-align: left;"><font color="#9999ff">[+919904983614]</font></div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
<a class="moz-txt-link-abbreviated" href="mailto:talk@x-query.com">talk@x-query.com</a>
<a class="moz-txt-link-freetext" href="http://x-query.com/mailman/listinfo/talk">http://x-query.com/mailman/listinfo/talk</a></pre>
    </blockquote>
    <br>
  </body>
</html>