PDA

View Full Version : Unique nodes with Xpath


fwaldron
10-15-2004, 07:27 AM
Hi
I have a set of 3 combo boxes and would like to have the results of the second 2 filtered by the selected text item in the first , and the results of the third filtered as a result of the first and second selected text items.

I need to select only unique text strings using XPATH,
How do I filter out all the other occurrences from the resulting node so I only load unique string values into the second combo box.
I am using the following code

<canvas height="200" width="500" debug="true">

<script>
<![CDATA[
function sendAlert(str,str2)
{
debug.write(str + " " + str2);
}

]]>
</script>


<!--all datasets xml documents returned from a remote webservice. -->

<dataset name="items" autorequest="true" src="http://vhav01web3/C_InvSpecialtyData/Service1.asmx/Get_Facilities" >

</dataset>


<dataset name="items2" autorequest="true" src="http://vhav01web3/C_InvSpecialtyData/Service1.asmx/Get_Specialty_By_Facility?facilityName=Boston" >
</dataset>

<dataset name="items3" autorequest="true" src="http://vhav01web3/C_InvSpecialtyData/Service1.asmx/Get_Sub_Specialty?facilityName=Bedford&amp;specialty=M edicine" >
</dataset>
<dataset name="items4" autorequest="true" src="http://vhav01web3/C_InvSpecialtyData/Service1.asmx/Get_Facility_Offering" >
</dataset>



<class name="mycombo" extends="combobox"
width="130"
shownitems="3"
defaulttext="choose one..." >
<method name="applyData" args="d">

this.itemToSelect = parseInt(d); // 1 based

</method>

<method event="oninit" reference="canvas">

var i = this.itemToSelect - 1; // 0 based

this.selectItemAt( i );

</method>

<method name="changeData" args="s">



myc3.textlistitem.setAttribute('datapath','items2:/NewDataSet[1]/Table/MedicalDisciplineName' );
myc3.textlistitem.doRequest();
</method>


</class>

<mycombo x="5" simplelayout="y" onselect="changeData(text)"
datapath="items:/items[1]/@select" name="myc2">

<textlistitem datapath="items:/items[1]/item" text="$path{'text()'}"
value="$path{'@value'}" />

</mycombo>


<class name="mycombo2" extends="combobox"
width="130"
shownitems="3"
defaulttext="choose one..." >
<method name="applyData" args="d">
this.itemToSelect = parseInt(d); // 1 based
</method>

<method event="oninit" reference="canvas">
var i = this.itemToSelect - 1; // 0 based
this.selectItemAt( i );
</method>

<method name="changeData2" args="s,y">


sendAlert('?facilityName=' + s + "&amp;specialty=" + y , s);

items3.setAttribute('SRC', 'http://vhav01web3/C_InvSpecialtyData/Service1.asmx/Get_Sub_Specialty?facilityName=' + s + "&amp;specialty=" + y );
item3.doRequest();
<!--http://vhav01web3/C_InvSpecialtyData/Service1.asmx/Get_Sub_Specialty?facilityName=Boston&specialty=Spinal Cord Injury-->
</method>


</class>

<mycombo2 simplelayout="x" y="120" onselect="changeData2(myc2.getAttribute('text'), this.getAttribute('text') )" datapath="items2:/NewDataSet[1]/Table/MedicalDisciplineName[/@select" name="myc3">
<textlistitem datapath="items4:/NewDataSet[1]/Table/MedicalDisciplineName"
text="$path{'${text()'}"
value="$path{'@value'}" />
</mycombo2>

<!--text="$path{'text()'}"
value="$path{'@value'}" />-->




<class name="mycombo3" extends="combobox"
width="130"
shownitems="3"
defaulttext="choose one..." >

<method name="applyData" args="d">
this.itemToSelect = parseInt(d); // 1 based
</method>


<method event="oninit" reference="canvas">
var i = this.itemToSelect - 1; // 0 based
this.selectItemAt( i );
</method>




</class>


<mycombo3 simplelayout="x" y="140" datapath="items3:/NewDataSet[1]/Table/Service[/@select" name="myc30">
<textlistitem datapath="items3:/NewDataSet[1]/Table/Service" text="$path{'text()'}"
value="$path{'@value'}" />


</mycombo3>




</canvas>

Thanks