XPATH readout - HAshmap/Array or Enum

Hi,
I am reading this from my xml file:
<Taxes>
                  <Tax TaxCode="code1" Amount="500.00"/>
                  <Tax TaxCode="code2" Amount="100.00"/>
                  <Tax TaxCode="code3" Amount="100.00"/>
                  <Tax TaxCode="code4" Amount="1000.00"/>
                  <Tax TaxCode="code5" Amount="2000.00"/>
                </Taxes>and am passing the Taxcodes as keys and the Amounts as values into a HashMap.
My Problem is, if there are more than 3 TaxCodes, i have to return the amounts of the "extra" Taxcodes as a summed value and forget about the other taxcodes. Thus leaving me with:
                  <Tax TaxCode="code1" Amount="500.00"/>
                  <Tax TaxCode="code2" Amount="100.00"/>
                  <Tax TaxCode="code3" Amount="3100.00"/>Is Hashmap the way to go here - or is there an easier way?

One simple suggestion now that a look closer at your code is to sum the values before you add them.
Where you have:
// combine the 2 nodeLists into a HashMap
                  for (int i = 0; i < nodes1.getLength(); i++) {
                          taxes.put( nodes.item(i).getNodeValue(), nodes1.item(i).getNodeValue());
                    }Do something along the lines of
        for (int i = 0; i < nodes1.getLength() && (i<2); i++) {
                   taxes.put( nodes.item(i).getNodeValue(), nodes1.item(i).getNodeValue());
        if(nodes1.getLength() >=3){
            int total = 0;
            for (int i = 2; i < nodes1.getLength(); i++) {
                   total += nodes1.item(i).getNodeValue());
            taxes.put( nodes.item(3).getNodeValue(), total);
        }*Note I hardcoded the limit on number of the codes (you might want to replace it), also you will need to convert the node values to numbers in order to sum them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How do you create array of enums for transitions in a state machine?

    Hello,
    I am trying to build a state machine, but, I am struggling with understanding the methods for determining which state to transition to next.  In other words, I have several states, but, I don't want to go in any particular sequence.  If I have states numbered 1 through 10, I want to be able to go 1-4-2-5-6-2-6-1-10 etc. in no particular order. I want the transition to the next state  (and actions) to be determined by the streaming data, which can be random and require access to any of my 10 states at any time and in any sequence.
    I saw this picture on the "Application Design Patterns: State Machines" white paper, but, it leaves out some important details.  How does one create the structure in BLUE shown in 3C?  When I try to create this array of enums, all of them are the same. I am not able to make a list of different enum values.  In other words, when I type in "2", then, all the values in the array display as "2."
    There is a nice, simple video example of a state machine for dispensing soda for $0.15, however, this state machine moves in a single sequence, from 5 cents, to 10 cents to dispense; it does NOT illustrate how to select a state "out of order."  I need to understand how a state machine can move from "5 cents" state to dispense directly, with the addition of 10 cents to the "5 cents" state.
    Can anyone suggest a really good tutorial on how to make the selector work in a state machine?  I have been reading some of the available material on ni.com, but, I can't find a good detailed explanation of how to do it.  I remain confused. 
    Or, can you just explain how they created the BLUE array in the attached picture?  Maybe I can figure it out from there.
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    next state.jpg ‏75 KB

    Hi Kathryn,
    Yes, this is EXACTLY what I want to accomplish...
    So it would basically run:
    State 1
    Read input
    Determine next state (say 3)
    State 3
    Read input
    Determine next state
    State
    Read input
    Determine next state
    And so on...
    But, I am quite new to programming Labview state machines, and can't figure out how to even start when the sequence of states is random instead of fixed!!! I can do 1,2,3,4, like the vending machine VI example, but,  not 1,3,2,2,2,5,2,1 etc. based on external input.  Is there some simple example case I can study?  I can't believe I am inventing this for the first time.
    "select the state to run" 
    But, HOW do I do this???????   This is exactly the question I am asking...how is this done?  Please see the attached 3-state system....how do I hook this up????  I am totally lost here...can you help me understand how to wire this thing??  In this simpe RED/GREEN/BLUE case, my input is just the number a user would input on the front panel....  Apparently, there are two files necessary... a vi and .ctl???  What  is .ctl?
    Thanks,
    Dave
    Attachments:
    forum nov 12 red green blue.vi ‏7 KB
    forum nov 12 red green blue.ctl ‏5 KB

  • EJB QL: Passing array of enum to SELECT * WHERE a IN () clause

    Hello,
    I am trying to pass an array of enum to EJB QL as followed:
    em.createQuery("FROM OrderInfo o WHERE o.ordStatus IN (:ordStatus)")
                     .setParameter("ordStatus", ordStatsStr)Note that o.ordStatus is of type enum OrderStatus.
    I've tried to set "ordStatus" as String (i.e. 'OPEN', 'CLOSED'), as well as an array of enum but EJB QL would not parse them (perhaps for a good reason). EJB QL (I use JBoss + Hibernate) threw the following exception (or similar depending on whether I passed in an array of enum or a String):
    org.hibernate.TypeMismatchException: named parameter [ordStatus] not of expected type;
    expected = class ....OrderStatus; but was =java.lang.StringCan someone show me the way to set the IN clause with an array of enum?
    Thanks

    I suppose that your enum declaration is like
    public enum OrderStatus{
    OPEN,
    CLOSED
    The exception remarks that the valid type must be OrderStatus. I think that you must change your sentence by
    em.createQuery("FROM OrderInfo o WHERE o.ordStatus IN (:ordStatus)")
    .setParameter("ordStatus", OrderStatus.OPEN);
    On the other hand, for the array option I think that you must use setParameterList like this
    OrderStatus options[] = new OrderStatus[2];
    options[0] = OrderStatus.OPEN;
    options[1] = OrderStatus.CLOSED;
    em.createQuery("FROM OrderInfo o WHERE o.ordStatus IN (:ordStatus)")
    .setParameterList("ordStatus", options);
    I hope it helps you
    hayken.

  • Finding the most common value in an array of enums

    Hello,
    I'm looking for an elegant way of finding the most common value in an array of enums
    My enum being:
    0 - Close
    1 - Open
    2 - Undefined
    For instance, if my array contains:
    Close, Close, Open, Close, Close, Open.
    The most common value would be "Close"
    I have created a very customized VI that allows me to obtain the desired result, but I'm really not proud of doing it this way, simply because I would have to modify it if I were to add a new value to my enum...
    If someone can share some ideas to enlighten me, I would REALLY appreciate it.
    Thanks in advance!
    Jorge
    Solved!
    Go to Solution.

    Here is the variant using the search method. This method will run N-1 times where N is the number of ENUM elements. Yes, it is a bit more complex than the brute force method but it would execute fairly quickly. The sort would probably be the time consuming task.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    ENUM Counter.vi ‏14 KB
    Enum.ctl ‏4 KB

  • Concatenate clusters to array with enums

    Hi I am trying to concatenate three 1D arrays filled with an i32 and an enum.
    When i look at my concatenated array i lose my enum information... It makes 0,1,2,3,4 etc... instead of the channel names??
    Does anyone have a solution for this?
    Best regards,
    Thijs
    Solved!
    Go to Solution.

    How exactly did you 'look' at the concatenated array? If you use a numeric indicator instead of enumerated, the VI will execute, but you will lose the enum names.
    However, if you probe the wire, and/or Right Click > Create Indicator... you should not encounter the problem, in which case the problem must lie somewhere else.

  • HashMaps and Arrays

    I am extracting data from MYSQL in a result set. The values are then stored in HashMap. The total count of rows would be around 650 - 700 approx. I get a Array out of Bound exception.
    (Note: I have a HashMap array- HashMap hm[] = new HashMap[800]; )
    Any one to comment on this. If you need any more information.. let me know...
    -Krish

    PMJain wrote:
    Why do you allocate a HashMap[]?
    you would need a single instance of HashMap to be populated with some key/value pairs
    where key might be your primary key and the value could be the object with the data from a single record.My guess is that Cubby was turning each result set row into a Map that mapped the column name to the row's value. Meh.

  • Having difficulty cluster convert to array of enumeratorsHi I have difficulty conver

    Hi I have difficulty converting a cluster of enumerators to array of enumerators, unlike unbundle and build_array vis that work.
    So If I have a unknown number of enumerators, I cannot use unbundle and build_array vis as they are fixed for decided number.
    I am using Labview 7.1. I am puzzled over its ability to convert.
    so here's the attached.
    Would appreciate your help.
    thanks in advance
    Attachments:
    cluster to array of enumerators.vi ‏24 KB

    The problem you are having is that your enumerated data elements are not the same.  Enumerated data types include the string value,  So, since you have moved None around in the list and taken away a value from each, LabVIEW doesn't consider the data types to be the same.
    I have attached three VIs showing options.
    The first uses the same enum type for all the values.  The issue here
    is that the value of None doesn't change.  But, you can also convert
    this into your array of enums instead of U16s.  Please note that if you
    went this route, you should probably use a type def so if you ever had
    to add an 8, you'd do it once.  Not knowing your ultimate goal, it is
    difficult to suggest a method, although I would use the last example.
    In the second, I changed your enums to rings.  The rings don't care what the string values are, so you can keep the different pull down lists as you had them in your original.
    The third uses the different enums you have and uses a typecast to a U16 array.
    The second and third examples lose its data meaning because you basically need to know how the values track back to the original data type.  The first keeps the data type.  But again, it may be beneficial in your case to have the values change based on which value is set ot None.
    Matthew
    Message Edited by Matthew Kelton on 09-02-2007 10:49 PM
    Attachments:
    cluster to array of enumerators.vi ‏14 KB
    cluster to array of enumerators (ring).vi ‏12 KB
    cluster to array of enumerators (typecast).vi ‏12 KB

  • An example of a state machine with transition array?

    I am looking at state machine design patterns and am interested particularly in a state machine with boolean trasition array which defines the next state to be executed using an array. Here, the index of the first “True” boolean in the boolean array corresponds to the index of the new state in the array of enums. Has anyone got an example of this design pattern as it would greatly help in my understanding of it. Refer to figure 3c in http://zone.ni.com/devzone/cda/tut/p/id/3024#toc2 for clarity on what i am asking for.
    Thanks in advance.

    That seems like a lot of extra work. Why not just use a queue, and queue up the enum you want to go to next? Look up examples on queued state machine. No need for an array and then a boolean to index that array. here is an example
    CLA, LabVIEW Versions 2010-2013

  • "-" character in enum not allowed?

    Hello,
    If I create an enum with the following items:
    "+", "-", "/" and "*", I cannot see the item "-" on the front panel as an option.
    Is it a restricted character to use in enum type? Before you say, I know I can just use a Ring type, but I just would like to learn why I see this behaviour?
    thanks!
    EDIT: same behaviour for the Text Ring....
    EDIT2: Menu Ring: also problem with "-"
    Solved!
    Go to Solution.

    This is indeed one problem of several with the use of separators in such controls, but:
    - If you must have multiple separators in a control, use a Text Ring. Head to Edit Items for the control, then untick Sequential values. You can reorder the items but keep their values in the order you want. For instance, you could have:
    A 0
    B 1
    C 2
    D 3
    - 10
    E 4
    F 5
    G 6
    - 11
    H 7
    I 8
    etc, and you'll end up with a drop down with multiple selectors. It's a little unwieldy though.
    - If you want to iterate through a text ring like the one above, you could just limit the number of iterations to the last item before your separator values start, e.g. 9.
    - Enums allow a lot more flexibility, as you can put things in in whatever order you wish and then select (e.g. cases in a case structure) by name, rather than by number. Much more readable, and you can deal with the separator selection with a default case (or specifically a hyphen case, in which you do nothing!). If you want to iterate through elements of the enum, create a 1D array of enum constants, selecting which entry to use at each iteration, then pass to an autoindexing for loop.
    - Whatever you do, make sure you type def the control!
    CLD

  • Why doesn't my XMLTable function work?

    Hi,
    I'm trying to read through my XML document using a XMLTable function, because a repetition of elements might occur. I wrote a SQL-script to test this function, but it does not give me the desired output. This is my script. I use a dummy table PETER_XML to pass the value to the XMLTable function. I would rather have done this directly with a PL/SQL variable, but that did not work.
    CREATE TABLE PETER_XML (AVY XMLTYPE);
    set serveroutput on size 100000
    set echo on
    set feedback on
    declare
    cursor c_avy is
    SELECT XMLRESPONSE."DepartureStation" DEPARTURE,
           XMLRESPONSE."FlightNumber"     FLIGHTNR
    FROM   PETER_XML,
           XMLTABLE(XMLNameSpaces('http://schemas.navitaire.com/WebServices' as "web",
                                  'http://schemas.xmlsoap.org/soap/envelope/' as "soapenv",
                                  'http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService' as "book",
                                  'http://schemas.navitaire.com/WebServices/DataContracts/Booking' as "book1",
                                  'http://schemas.microsoft.com/2003/10/Serialization/Arrays' as "arr",
                                  'http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations' as "enum",
                                  'http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService' as "ns0",
                                  'http://schemas.navitaire.com/WebServices/DataContracts/Booking' as "ns1" ),
                    '//GetAvailabilityRequest/TripAvailabilityRequest/AvailabilityRequests/AvailabilityRequest'
                    PASSING PETER_XML.AVY
                    COLUMNS
                      "DepartureStation" varchar2(3) PATH 'DepartureStation',
                      "FlightNumber"     varchar2(4) PATH 'FlightNumber'
                   ) XMLRESPONSE;
    l_response clob := '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://schemas.navitaire.com/WebServices" xmlns:book="http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService" xmlns:book1="http://schemas.navitaire.com/WebServices/DataContracts/Booking" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:enum="http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations">
       <soapenv:Header>
          <web:Signature>bnuOiHCVb3k=|Gx+eTRcZ5ABozAy8MosBFwagyUw7zrRXf1iprmw9Q4W17wt8SDpjYV2HwZRGIHYtE46UFBJw/aFyKVqjToEAfSTfh7cePm4r9JJwcIveDc75NuxnzoY14pKC+WLYDzE0MaALra4i/tI=</web:Signature>
          <web:ContractVersion>340</web:ContractVersion>
       </soapenv:Header>
       <soapenv:Body>
              <ns0:GetAvailabilityRequest xmlns:ns0 = "http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService">
                       <ns1:TripAvailabilityRequest xmlns:ns1 = "http://schemas.navitaire.com/WebServices/DataContracts/Booking">
                                 <ns1:AvailabilityRequests>
                                          <ns1:AvailabilityRequest>
                                                    <ns1:DepartureStation>AMS</ns1:DepartureStation>
                                                    <ns1:ArrivalStation>CTA</ns1:ArrivalStation>
                                                    <ns1:BeginDate>2013-07-13T00:00:00</ns1:BeginDate>
                                                    <ns1:EndDate>2013-07-13T00:00:00</ns1:EndDate>
                                                    <ns1:CarrierCode>HV</ns1:CarrierCode>
                                                    <ns1:FlightNumber> 547</ns1:FlightNumber>
                                                    <ns1:FlightType>All</ns1:FlightType>
                                                    <ns1:PaxCount>1</ns1:PaxCount>
                                                    <ns1:Dow>Daily</ns1:Dow>
                                                    <ns1:CurrencyCode>EUR</ns1:CurrencyCode>
                                                    <ns1:DisplayCurrencyCode>EUR</ns1:DisplayCurrencyCode>
                                                    <!--ns1:SourceOrganization>COO</ns1:SourceOrganization-->
                                                    <ns1:MaximumConnectingFlights>0</ns1:MaximumConnectingFlights>
                                                    <ns1:AvailabilityFilter>Default</ns1:AvailabilityFilter>
                                                    <ns1:ProductClassCode>NG</ns1:ProductClassCode>
                                                    <ns1:SSRCollectionsMode>None</ns1:SSRCollectionsMode>
                                                    <ns1:InboundOutbound>Both</ns1:InboundOutbound>
                                                    <ns1:NightsStay>0</ns1:NightsStay>
                                                    <ns1:IncludeAllotments>true</ns1:IncludeAllotments>
                                                    <ns1:FareTypes>
                                                              <ns2:string xmlns:ns2 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays">T</ns2:string>
                                                    </ns1:FareTypes>
                                                    <ns1:PaxPriceTypes>
                                                              <ns1:PaxPriceType>
                                                                       <ns1:PaxType>ADT</ns1:PaxType>
                                                              </ns1:PaxPriceType>
                                                    </ns1:PaxPriceTypes>
                                                    <ns1:JourneySortKeys>
                                                              <ns2:JourneySortKey xmlns:ns2 = "http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations">EarliestDeparture</ns2:JourneySortKey>
                                                    </ns1:JourneySortKeys>
                                                    <ns1:IncludeTaxesAndFees>false</ns1:IncludeTaxesAndFees>
                                                    <ns1:FareRuleFilter>Default</ns1:FareRuleFilter>
                                                    <ns1:LoyaltyFilter>MonetaryOnly</ns1:LoyaltyFilter>
                                                    <ns1:TravelClassCodeList>
                                                              <ns2:string xmlns:ns2 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays">Y</ns2:string>
                                                    </ns1:TravelClassCodeList>
                                          </ns1:AvailabilityRequest>
                                 </ns1:AvailabilityRequests>
                                 <ns1:LoyaltyFilter>MonetaryOnly</ns1:LoyaltyFilter>
                       </ns1:TripAvailabilityRequest>
              </ns0:GetAvailabilityRequest>
       </soapenv:Body>
    </soapenv:Envelope>';
    begin
    dbms_output.put_line ('Start');
    insert into peter_xml (avy) values ( XMLTYPE(l_response) );
    dbms_output.put_line ('Insert processed ' || to_char(sql%rowcount) || ' rows.' );
    for r_avy in c_avy loop
       dbms_output.put_line ( 'Departure ' || r_avy.departure || ' Flightno. ' || r_avy.flightnr );
    end loop;
    end;
    rollback;
    The script runs fine, but the problem is that I do not get any output form the cursor for-loop. When I address the elements using 'ns1:etc' I get an error, which suggests that the function is actually reading the XML. Since it gave no output, I started including all these XMLNameSpaces.
    Can anyone let me know what I'm missing?
    And if I can pass the value with a PL/SQL variable, it would save me the use of a dummy table. That would be nice.
    Thanks in advance.
    Peter

    Hi Peter,
    Since it gave no output, I started including all these XMLNameSpaces.
    All these namespaces have meaning, don't include them blindly, but if you do, use them.
    The main XQuery expression doesn't reference any of the necessary namespaces.
    Here's a simplified version that gives the expected output.
    Please note that I only use the namespaces I need to resolve the XQuery :
    declare
      cursor c_avy (p_xmlresponse in xmltype) is
        select x.DEPARTURE
             , x.FLIGHTNR
        from xmltable(
               xmlnamespaces(
                 'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
               , 'http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService' as "ns0"
               , 'http://schemas.navitaire.com/WebServices/DataContracts/Booking' as "ns1"
             , '/soap:Envelope/soap:Body/ns0:GetAvailabilityRequest/ns1:TripAvailabilityRequest/ns1:AvailabilityRequests/ns1:AvailabilityRequest'
               passing p_xmlresponse
               columns
                 DEPARTURE varchar2(3) path 'ns1:DepartureStation'
               , FLIGHTNR  varchar2(4) path 'ns1:FlightNumber'
             ) x ;
      l_response clob := '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://schemas.navitaire.com/WebServices" xmlns:book="http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService" xmlns:book1="http://schemas.navitaire.com/WebServices/DataContracts/Booking" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:enum="http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations">
       <soapenv:Header>
          <web:Signature>bnuOiHCVb3k=|Gx+eTRcZ5ABozAy8MosBFwagyUw7zrRXf1iprmw9Q4W17wt8SDpjYV2HwZRGIHYtE46UFBJw/aFyKVqjToEAfSTfh7cePm4r9JJwcIveDc75NuxnzoY14pKC+WLYDzE0MaALra4i/tI=</web:Signature>
          <web:ContractVersion>340</web:ContractVersion>
       </soapenv:Header>
       <soapenv:Body>
              <ns0:GetAvailabilityRequest xmlns:ns0 = "http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService">
                       <ns1:TripAvailabilityRequest xmlns:ns1 = "http://schemas.navitaire.com/WebServices/DataContracts/Booking">
                                 <ns1:AvailabilityRequests>
                                          <ns1:AvailabilityRequest>
                                                    <ns1:DepartureStation>AMS</ns1:DepartureStation>
                                                    <ns1:ArrivalStation>CTA</ns1:ArrivalStation>
                                                    <ns1:BeginDate>2013-07-13T00:00:00</ns1:BeginDate>
                                                    <ns1:EndDate>2013-07-13T00:00:00</ns1:EndDate>
                                                    <ns1:CarrierCode>HV</ns1:CarrierCode>
                                                    <ns1:FlightNumber> 547</ns1:FlightNumber>
                                                    <ns1:FlightType>All</ns1:FlightType>
                                                    <ns1:PaxCount>1</ns1:PaxCount>
                                                    <ns1:Dow>Daily</ns1:Dow>
                                                    <ns1:CurrencyCode>EUR</ns1:CurrencyCode>
                                                    <ns1:DisplayCurrencyCode>EUR</ns1:DisplayCurrencyCode>
                                                    <!--ns1:SourceOrganization>COO</ns1:SourceOrganization-->
                                                    <ns1:MaximumConnectingFlights>0</ns1:MaximumConnectingFlights>
                                                    <ns1:AvailabilityFilter>Default</ns1:AvailabilityFilter>
                                                    <ns1:ProductClassCode>NG</ns1:ProductClassCode>
                                                    <ns1:SSRCollectionsMode>None</ns1:SSRCollectionsMode>
                                                    <ns1:InboundOutbound>Both</ns1:InboundOutbound>
                                                    <ns1:NightsStay>0</ns1:NightsStay>
                                                    <ns1:IncludeAllotments>true</ns1:IncludeAllotments>
                                                    <ns1:FareTypes>
                                                              <ns2:string xmlns:ns2 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays">T</ns2:string>
                                                    </ns1:FareTypes>
                                                    <ns1:PaxPriceTypes>
                                                              <ns1:PaxPriceType>
                                                                       <ns1:PaxType>ADT</ns1:PaxType>
                                                              </ns1:PaxPriceType>
                                                    </ns1:PaxPriceTypes>
                                                    <ns1:JourneySortKeys>
                                                              <ns2:JourneySortKey xmlns:ns2 = "http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations">EarliestDeparture</ns2:JourneySortKey>
                                                    </ns1:JourneySortKeys>
                                                    <ns1:IncludeTaxesAndFees>false</ns1:IncludeTaxesAndFees>
                                                    <ns1:FareRuleFilter>Default</ns1:FareRuleFilter>
                                                    <ns1:LoyaltyFilter>MonetaryOnly</ns1:LoyaltyFilter>
                                                    <ns1:TravelClassCodeList>
                                                              <ns2:string xmlns:ns2 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays">Y</ns2:string>
                                                    </ns1:TravelClassCodeList>
                                          </ns1:AvailabilityRequest>
                                 </ns1:AvailabilityRequests>
                                 <ns1:LoyaltyFilter>MonetaryOnly</ns1:LoyaltyFilter>
                       </ns1:TripAvailabilityRequest>
              </ns0:GetAvailabilityRequest>
       </soapenv:Body>
    </soapenv:Envelope>';
    begin
      for r_avy in c_avy (xmltype(l_response)) loop
        dbms_output.put_line ( 'Departure ' || r_avy.departure || ' Flightno. ' || r_avy.flightnr );
      end loop;
    end;
    Indeed, you don't need an intermediate table for this requirement. However, and depending on your db version, storing the XML in a binary XMLType table may improve performance dramatically.
    For small contents, you probably won't see a difference between the two approaches, but just so you know in case you have to deal with big XMLs in the future.

  • Selecting sequence of operations

    Imagine that you have 5 independent measurements using 3 instruments.
    I have them defined in separate flat sequence structures. Depending on front panel input, I want the ability to run these measurements in a user-defined sequence - say 1,2,3,4,5 or 1,3,5,2,4, or ...
    How do I do that ?

    I think you are being slightly misunderstood, it seems the Flat Sequences are only used to specify the individual measurements, and not to control the order like some are suggesting.  If that works, and makes you happy, so be it.  I'll take your advice and just consider those to be subVIs, one for each of the 5 measurements.
    When I want a quick UI like this I reach for an Event Structure, and use the timeout case for the business end.  Inside the timeout case I may put a Queued State Machine or in this case I would just use a simple For Loop.  In the example I create a simple array of enums, with one value for each measurement.  When Go is pressed, the Event Structure timeout is fired, and the array of measurements is autoindexed by a For Loop.  Inside the Loop is a Case Structure to handle the individual measurements, just drop your 'subVIs' in there.
    Simple and quick, lets you spend more time measuring and less time coding.
    Attachments:
    SimpleMeasurementGUI.vi ‏13 KB

  • Create a beep at specific intervals

    Hello,
    I was only introduced to LabView today and must create a program that will produce a beep sound at (random) intervals and then repeat the cycle for a behavioral experiment I am conducting.
    In other words, I have to create something with the following trial pattern: 3s silence, 1s beep, 2s silence, 1s beep, 5s silence, 1s beep (repeat cycle).
    I got as far adding the beep.vi and making the necessary adjustments according to this tutorial: http://www.ehow.com/how_12122458_create-sound-numbers-labview.html
    but another issue I came across is the lack of synchronization between the Boolean function and the sound production from the beep (It will continue to beep after pressing "stop"). Additionally, changing the frequency values did not change its tone...and a single beep.v's frequency would not be adjustable for the trial pattern I have mentioned above.
    I would greatly appreciate any help (visuals would be much appreciated as well). I am a complete newbie to programming and my ineptitude has been stressing me out all day.
    Thank you!!!!

    Hi unevolved,
    Sorry, I forgot to add another question. May I ask what LabVIEW version that you are running on?
    Based on what you mention on the first point: following trial pattern: 3s silence, 1s beep, 2s silence, 1s beep, 5s silence, 1s beep (repeat cycle), I believe you'll need to use something like a state machine. I believe this might explain about state machines: http://www.ni.com/white-paper/7595/en/ and http://www.youtube.com/watch?v=JyJxNrgABsI.
    I have created a rough program based on your cycles. The below screenshot is what i can think of based on your requirements. Presuming that you have read about the state machines from the link I have provided, I'll explain the code   
    Basically, I have created 3 states, cycle 1 (3s silence, 1s beep), cycle 2 (2s silence, 1s beep) and cycle 3 (5s silence, 1s beep). First and foremost, you'll need to create a basic state machine structure which consists of a enum (with the state names - http://labviewwiki.org/Enumerated_type), while loop, shift registers (which passes the value from the current iteration to the next) and case structure (each with their own state). 
    As you can see, I have a main case structure which controls if the loop operation and within it is the nested case structure which is the state machine itself. For each case, I have an array of enums (which I have specified the names to be Silence and Beep) and a for loop which contains the case structure which does both silence and beep.
    As you noticed that the for loop has a indexing tunnel. This allows the for loop to run 2 iterations. On the first iteration, the 1st index array: Silence will be as an input for the case structure and executes Silence case state. On the second iteration, the second index array: Beep will execute the Beep case state.
    The below is the silence state for the 1st for loop iteration:
    The below is the beep state for the 2nd for loop iteration:
    For Silence, I have used wait(ms) to provide the pause before it goes to the next state "beep".
    The whole operation will basically repeats from Cycle1 -> Cycle2 -> Cycle3 until you hit the stop button. If you hit the stop button, the main case structure will be as below:
    Which should stop the while loop. 
    Hope it helps.
    Warmest regards,
    Lennard.C
    Learning new things everyday...

  • Report Viewer localization

    Hello Community!
    Concerning the content of the document http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e06b8953-a62b-2d10-38b9-ca71f747e2b1?QuickLink=index&… the russian language is supported.
    Do I have to install a language pack on the client or are the language packs included in the current redistributable version of the runtime package?
    Thank you for the information!

    Hi Alexander,
    If you had tried the code in the KBA you would see the language is there.
    I do not have a Russian report but here's one in German that will not run unless the locale is set to German. As you can see Russian is listed.
    Complete code looks like this:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using CrystalDecisions.ReportAppServer.CommonControls;
    namespace CrystalReportWpfApplication3
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
        public partial class Window1 : Window
            CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            public Window1()
                InitializeComponent();
                Array valArray = Enum.GetValues(typeof(CrystalDecisions.ReportAppServer.CommonControls.CeLocale));
                foreach (object obj in valArray)
                    listBox1.Items.Add(obj);
            private void reportViewer_Loaded(object sender, RoutedEventArgs e)
            private void button1_Click(object sender, RoutedEventArgs e)
                reportViewer.Owner = this;
                doc.Load(@"D:\Test.rpt");
                reportViewer.ViewerCore.Visibility = Visibility.Visible;
                reportViewer.ViewerCore.ReportSource = doc;
            private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
                //this is the routine to set the default language locale for the report. Must be done before the report is loaded.
                CrystalDecisions.ReportAppServer.CommonControls.CeLocale myceLocale = (CrystalDecisions.ReportAppServer.CommonControls.CeLocale)listBox1.SelectedItem;
                try
                    doc.ReportClientDocument.LocaleID = (CrystalDecisions.ReportAppServer.DataDefModel.CeLocale)myceLocale;
                catch (Exception ex)
                    MessageBox.Show("ERROR: " + ex.Message);
    Thanks again
    Don

  • TicTacToe - Objects

    Hey guys, I've been working on an objected-oriented tic-tac-toe game to get acquainted with the language, etc...
    I'm having problems with the checkMove(int) method, in the board object. No matter what, the value returned is always true, even if the move is legal (in which case the value returned should be false). Here is the code:
    Board object:
    public class Board {
      private String[][] _board = new String[3][3];
      public Board() {
       int x = 0;
       for (int row = 0;  row < 3;  row++) {
         for (int column = 0;  column < 3;  column++) {
           x += 1;
           _board[row][column] = " " +x +" ";
      }   // End of constructor.
        public boolean checkMove(int position) {
        boolean test = false;
        switch (position) {
          case 1: {if (_board[0][0] != " " +1 +" ") {test = true;} break;}
          case 2: {if (_board[0][1] != " " +2 +" ") {test = true;} break;}
          case 3: {if (_board[0][2] != " " +3 +" ") {test = true;} break;}
          case 4: {if (_board[1][0] != " " +4 +" ") {test = true;} break;}
          case 5: {if (_board[1][1] != " " +5 +" ") {test = true;} break;}
          case 6: {if (_board[1][2] != " " +6 +" ") {test = true;} break;}
          case 7: {if (_board[2][0] != " " +7 +" ") {test = true;} break;}
          case 8: {if (_board[2][1] != " " +8 +" ") {test = true;} break;}
          case 9: {if (_board[2][2] != " " +9 +" ") {test = true;} break;}
          default: {test = true; break;}
        }   // End of switch.
        return test;
      } // End of method checkMove().
    }   // End of class Board.The relevant part of the main code is:
    do {
              System.out.println(player1.getName() +", it is your turn. Where would you like to play?"); 
              position = TextIO.getlnInt();
              illegalMove = board.checkMove(position);
            } while(illegalMove == true);Any corrections and general criticism is greatly appreciated :)

    cotton.m wrote:
    A few comments. This
    the value returned is always true, even if the move is legal (in which case the value returned should be false).Seems logically backwards to me. A method called checkMove I would expect to return true for legal and false for illegal. But maybe that's just me.You are completely right. However, it just so happened that in the main method, I had the variable illegalMove. Therefore it makes sense that illegalMove is true when there is an illegalMove, and illegalMove is false when there isnt.
    cotton.m wrote:
    Another comment would be that I wouldn't use an array of Strings for the board. Why not ints? (or enums or bytes) Well ints anyway. I mean you only have three options right? X, O or empty. Storing 9 different strings is a pain now and going to be worse later when you check the results (to look for a winner or the "right" place to move next)Sorry for the possible naivet of this question, but how would you create an array of enums or bytes, and how would you apply it to this situation? seems like an interesting option.
    Actually, i already had a method called checkWin() which was working. In fact, it was just this checkMove() method which wasnt working.
    corlettk wrote:
    Looks like an epic brainfart to me... if 1..9 then true, else true. Huh? In my (very limited) understanding, the default case just takes into account any possible input from the user which surpasses the values of 1-9, thus not being located on the board, which would classify it as an illegal move.
    Thanks for all of the help guys, I really appreciate it :)

  • Adding generics causes error in code

    Hi,
    I have written a method to see if a supplied array of enums contains the specified enum.
    The first version of the code had warnings:-
    public static boolean enumInList(Enum type, Enum[] typesList) {
              if (type == null) {
                   return (true);
              for (Enum enum1 : typesList) {
                   if ((type.compareTo(enum1) == 0)) {
                        return (true);
              return (false);
         }...the warnings were 'Enum is a raw type. References to generic type Enum<E> should be parameterized'
    When I removed these the code looks as follows:-
    public static boolean enumInList(Enum<?> type, Enum<?>[] typesList) {
              if (type == null) {
                   return (true);
              for (Enum<?> enum1 : typesList) {
                   if ((type.compareTo(enum1) == 0)) {
                        return (true);
              return (false);
         }The warnings disappeared but the 'compareTo' now as a serios error which says:-
    The method compareTo(capture#2-of ?) in the type Enum<capture#2-of ?> is not applicable for the arguments (Enum<capture#3-of ?>)
    So by removing the warnings I have made the code worse but removing the warnings is the correct thing to so.
    Therefore is there a way i can write to code to have both no warnings or errors but without having to resort to using annotation to suppress the warnings.
    Thanks,
    Dave.

    the warning message is telling you that the enum compareTo method is expecting an enum of the same type, whereas your method definition specifies two enums of potentially different types. you should need to introduce a generic type indicating that the two enum types are equivalent:
    public static <E extends Enum<E>> boolean enumInList(Enum<E> type, Enum<E>[] typesList)this will indicate that you expect 2 enum params with the same type.
    that said, i have no idea why you are using compareTo to test for equality. either use "type.equals(enum1)", or better yet, "type == enum1" (which has the benefit of being null-safe).

Maybe you are looking for