Thank you very much for our answers.
Here is the exact algorithm:
                for (var i = 0; i < 10; ++i)
                {
                        var n = $($("virtual-sensor",data).get(i)).attr("name");
                        if (n!=null) gsn.vsbox.add(n); // add the selection to 
a box
                }
Knowing that data is a xml object and virtual-sensor an id of this
data.
Here is an example of the variable data:

<?xml version="1.0" encoding="ISO-8859-1"?>
<gsn name="GSN Server" author="My name" email="my email address"
description="Not Provided">
<virtual-sensor name="templatevirtualsensor" last-
modified="1191537808156" description="Not Specified, please edit the
file $INSTALL_PATH/virtual-sensors/template.xml.">
</virtual-sensor>
<virtual-sensor name="testsvg" last-modified="1191537808140"
description="Not Specified, please edit the file $INSTALL_PATH/virtual-
sensors/networkPlotter.xml">
        <field name="plot" type="binary:image/svg+xml">/field?
vs=TESTSVG&field=PLOT&pk=66321</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563879750</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/networkPlotter.xml</field>
        <field name="plot" type="binary:image/svg+xml">/field?
vs=TESTSVG&field=PLOT&pk=66322</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563879750</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/networkPlotter.xml</field>
</virtual-sensor>
<virtual-sensor name="localsystemtime" last-modified="1191537808125"
description="Not Specified, please edit the file $INSTALL_PATH/virtual-
sensors/localTimeVS.xml.">
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563879265</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/localTimeVS.xml.</field>
</virtual-sensor>
<virtual-sensor name="memoryplotvs" last-modified="1191537808125"
description="Not Specified, please edit the file $INSTALL_PATH/virtual-
sensors/memoryPlotVS.xml">
        <field name="data" type="binary:image/jpeg">/field?
vs=MEMORYPLOTVS&field=DATA&pk=5367</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563876812</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/memoryPlotVS.xml</field>
</virtual-sensor>
<virtual-sensor name="gpsvs" last-modified="1191537808140"
description="Virtual sensor producing random locations and sensor
readings for testing in GPS applications.">
        <field name="latitude" type="double" description="tested
desc">255.9119</field>
        <field name="longitude" type="double">-122.1419</field>
        <field name="temperature" type="double">25.5</field>
        <field name="light" type="int">650</field>
        <field name="camera" type="binary:image/jpeg">/field?
vs=GPSVS&field=CAMERA&pk=21846</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563879187</field>
        <field name="type" category="predicate">test-sensor</field>
        <field command="ploppy" name="plop1" category="input"
type="radio:apple|orange|banana" description="one"></field>
        <field command="ploppy" name="plop2" category="input"
type="*checkbox:apple|orange|banana" description="two"></field>
        <field command="ploppy" name="plop3" category="input"
type="select:apple|orange|banana" description="three"></field>
        <field command="test" name="reset1" category="input" type="byte"></
field>
        <field command="test" name="reset2" category="input" type="*binary:
2mb" description="Files Size of 2MB max, The * means optional."></
field>
</virtual-sensor>
<virtual-sensor name="remoteaccessdemo" last-modified="1191537808156"
description="Not Specified, please edit the file $INSTALL_PATH/virtual-
sensors/remoteTest.xml">
        <field name="data" type="binary:image/jpeg">/field?
vs=REMOTEACCESSDEMO&field=DATA&pk=5367</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563876812</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/remoteTest.xml</field>
</virtual-sensor>
<virtual-sensor name="gps2" last-modified="1191537808156"
description="Not Specified, please edit the file $INSTALL_PATH/virtual-
sensors/localTimeVS.xml.">
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563879265</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/localTimeVS.xml.</field>
        <field name="latitude" category="predicate">37.4</field>
        <field name="longitude" category="predicate">-122.1</field>
</virtual-sensor>
<virtual-sensor name="memorymonitorvs" last-modified="1191537808156"
description="Not Specified, please edit the file $INSTALL_PATH/virtual-
sensors/memoryDataVS.xml">
        <field name="heap" type="bigint">11202712</field>
        <field name="non_heap" type="bigint">25021096</field>
        <field name="pending_finalization_count" type="integer">0</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563879828</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file
            $INSTALL_PATH/virtual-sensors/memoryDataVS.xml</field>
        <field name="latitude" category="predicate">37.5419</field>
        <field name="longitude" category="predicate">-122.1419</field>
</virtual-sensor>
<virtual-sensor name="invmaccess" last-modified="1191537808140"
description="Not Specified, please edit the file $INSTALL_PATH/virtual-
sensors/remoteTest.xml">
        <field name="data" type="binary:image/jpeg">/field?
vs=INVMACCESS&field=DATA&pk=5367</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563876812</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/remoteTest.xml</field>
</virtual-sensor>
<virtual-sensor name="multiformattemperaturehandler" last-
modified="1191537808140" description="Presents how you can have a
virtual sensor handling and parsing only a specific groups of packets
produced by a wrapper.">
        <field name="temperature" type="double">66.8</field>
        <field name="timed" type="long" description="The timestamp associated
with the stream element">1192563878765</field>
        <field name="geographical" category="predicate">Not Specified, please
edit the file $INSTALL_PATH/virtual-sensors/localTimeVS.xml.</field>
</virtual-sensor>
</gsn>



I'm still not sure on what it does... But I know that it works.


On 16 oct, 18:52, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> On Oct 16, 2007, at 12:24 PM, Andy Matthews wrote:
>
> > // creates a new, empty jQueru object
> > $(
> >    // create a new jQuery object using virtual-sensor
> >    // as the selector, with 'data' as the context
> >    // and it returns the ith record in that query into
> >    // an array.
> >    $("virtual-sensor",data).get(i)
> > // this gets all records that have an attribute of name
> > ).attr("name");
>
> A couple notes:
> 1. It looks like the selector is converting a jQuery object into a
> DOM element and then back into a jQuery object. Seems a little
> convoluted. I think the same thing can be achieved this way (assuming
> that "i" is coming from somewhere earlier in the script):
>
> $('virtual-sensor:eq(' + i + ')', data).attr('name');
>
> 2. The attr('name') part is actually returning the value of the name
> attribute. It's not filtering the matched set of elements.
>
> > The problem is that this code will never work as written. The
> > author is
> > trying to
> > Use 'virtual-sensor' as a selector, but in this setup, they're
> > acting as if
> > it's an HTML tag, which it's not. It should be '.virtual-sensor' or
> > '#virtual-sensor'
>
> Actually, if this is an XML file, it's quite possible that there is a
> <virtual-sensor> element.
>
> --Karl
>
>
>
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:jquery-
> > [EMAIL PROTECTED] On
> > Behalf Of charliend
> > Sent: Tuesday, October 16, 2007 9:05 AM
> > To: jQuery (English)
> > Subject: [jQuery] Can't understand a Jquery statement
>
> > Hello all,
>
> > I'm beginning working on a project which has been writing using
> > Jquery (I'm
> > novice) and I really can't understand that line:
> > $($("virtual-sensor",data).get(i)).attr("name");
>
> > Can you traduce it to me?
> > Thank you
> > Charlie

Reply via email to