[xsl] Here is my MSXML scripting Q - searching - revistied

Subject: [xsl] Here is my MSXML scripting Q - searching - revistied
From: "Walter Torres" <walter@xxxxxxxxx>
Date: Thu, 3 May 2001 18:28:35 -0500
It seems that I was not clear with my problem statement, and my examples
were not correct.

To correct my examples from the first mesage...

this...      srchType = 'events/call_event/cal_event_type';
should be... srchType = 'events/call_event/curr_dest';

and this...  searchStr = 'Cyndi';
should be... searchStr = 'Vincent';

Sorry for the confusion!  <:(

Now, for (I hope) a better explaination...

<Point of interest>
    All this (below) is to happen after the primary data
    and XSL has created an HTML Table and displayed it.
    I am tring to let the user search on displayed data
    and then display the subset of rows containing the
    search data.

    I have a select list that contains all the fields (nodes)
    that can be searched and a text box so the user can enter
    what string they wish to search for.
    Once the usere hits the SEARCH button, the function below
    is called into action so the user can see any found items.

I (think I) need a function that I can pass parameters to so it can look for
a given string in a given NODE.

If found, retrieve its parent NODE, and all its siblings and clone it to a
temp XML object.

If you look at the sample XML structure (below) the NODEs that will be
searched are 6 levels deep, they are children of the 'call_event' NODE.

So when a match is found I need to take the 'interaction' NODE (4 levels
down), and all its children, where the match was found and clone it into a
temp XML object.

You can see in my sample below that I have created a shell XML structure
(strXMLshell) to the 3th level so that the cloned NODES can be dropped right
in.

My function (below) does half of what I need it to do

It will find a match, but it only pulls out to the 'call_event' NODE level.

And then it clones that structure to the second level in the temp object,
not the 4th as needed.

Problem statement:

  Problem 1:
    I don't know how to tell the process it to go back
    up the tree and grap the entire 'interaction' NODE
    when it finds a match.

  Proble 2:
     I don't know how to clone that found NODE tree into
     the temp object at level 4.

I hope this explains a bit better.

Any ideas on this?

Thanks

Walter

PS: A few have written to me offline with ideas, but I
    don't know how to place them within this 'search on
    demand' world I am trying to make.

=================================
// We need a blank XML Object to store found items into
// We need to create the shell NODES...
var strXMLshell = "<?xml version='1.0'?>
                   <callEvent><response><interaction_list>
                   </interaction_list></response></callEvent>";

<!-- above breaks are for email only -->

// Load our XML String into the Object
objXMLset = load_XML_string ( strXMLshell );

=================================

srchType = 'events/call_event/curr_dest';
searchStr = 'Vincent';

=================================

// This will search the specified node type for given string
function search(searchStr, srchType)
{
   // searchStr = string to look for
   // srchType  = NODE to searach in

   // Make ure we have something to search for
   if ( searchStr == '' )
   {
      alert ( 'enter something.' );
      return false
    }

   // What NODE do we search from and subNODE was selected
   var mainNode   = callEvent/response/interaction_list/interaction';
   var searchNode = mainNode + '/' + srchType;

   // Retrieve the NODES from our selected NODE path
   var objNodeItems = objXMLdata.selectNodes(searchNode);

   for (i = 0; i < objNodeItems.length; i++)
   {
      var currNode = objXMLdata.selectNodes(searchNode).item(i);

      // Do the search
      if ( currNode.text.search(searchStr) != -1)
      {
         var cloneTree =
objXMLdata.selectNodes(mainNode).item(i).cloneNode(true);
         objXMLset.documentElement.insertBefore(cloneTree,
objXMLset.documentElement.lastChild);
      }

   }	// for (i = 0; i < objNodeItems.length; i++)

   // Place found data into display via XSL
   top.contactDisplay.dataTarget.innerHTML =
objXMLset.transformNode(objXSLdoc);

   // Reset the objXMLset object for the next search
   // Create out blank XML Shell
   loadBlankXML();
}


=================================



===========================================================
-- sample record, 1 of 4 in my demo set --

<callEvent>
   <response>
      <interaction_list>
         <interaction id='19766'>
            <timestamp>2001-04-16T04:30:32</timestamp>
            <media_type id='103'>Phone</media_type>
            <channel id='1'>-</channel>
            <ani></ani>
            <dnis></dnis>
            <route_type>I</route_type>
            <events>
               <call_event id='34757'>
                  <timestamp>2001-04-16T04:30:32</timestamp>
                  <call_event_type id='98'>eMail</call_event_type>
                  <customer id='2124'>Harris</customer>
                  <curr_dest id='103'>Vincent</curr_dest >
                  <to_dest id='1'>-</to_dest>
                  <nav_code id='1'>-</nav_code>
                  <rule id='1'>-</rule>
                  <greeting id='1'>-</greeting>
                  <call_type id='1'>-</call_type>
                  <ext_call id='1'>-</ext_call>
                  <old_call_record id='1'>-</old_call_record>
                  <product id='1'>-</product>
                  <reason id='198'>Case Resolution</reason>
                  <detailed_comment>Closed issue</detailed_comment>
               </call_event>
            </events>
         </interaction>
      </interaction_list>
   </response>
</callEvent>

=====================================

eof



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread