Newbie Question: Rules: Functions: How to compare String based type?

I have some XML facts in my rules dictionary defined by the following schema (fragments shown)
<xs:simpleType name="VarType">
   <xs:restriction base="xs:string">
      <xs:enumeration value="Foo"/>
      <xs:enumeration value="Bar"/>
      <xs:enumeration value="Baz"/>
      <xs:enumeration value="Qux"/>
   </xs:restriction>
</xs:simpleType>
<xs:complexType name="ProgType">
   <xs:sequence>
      <xs:element name="ID" type="xs:string"/>
      <xs:element name="var" type="VarType" maxOccurs="unbounded"/>
   </xs:sequence>
</xs:complexType>
Which means that a Prog of ProgType has an ID and a "list" of "var" strings restricted to bounds specified by VarType.
The issue comes when I try to create a Rules Function operating on these types.
Function-> boolean containsVar(ProgType prog,VarType var) (built using the Functions tab of the Rules editor)
for (String v : prog.var ){
   if (v == var){
      return true
return false
The problem we run into here is typing. If v is declared a String, as here, then v == var is invalid because types don't match. But I can't declare v a VarType due to
RUL-05583: a primitive type or fact type is expected, but neither can be found.
This problem may stem from the fact the Java's String is declared final and can't be subclassed, so the JAXB translation to Java may have to wrap it, futzing ==/equals() in the process.
SO... How do I create this method and compare these values?
TIA
Edited by: wylderbeast on Mar 10, 2011 9:15 AM - typos
Edited by: wylderbeast on Mar 10, 2011 9:18 AM

And here's the answer.
var.value() seems to return the String value of the type
so the comparison becomes
(v == var.value())
Live and learn....

Similar Messages

  • How to compare string in a case-insensitive manner using JavaScript?

    Hello everyone,
    Now I have a javascript to compare checkbox's value with user's input, but now seems it only can compare case-sensitively, does some one know if there is a function in javascript that it can compare string case-insensitively ?
    Here is my script :
    function findOffice(field)
    var name;
    name=prompt("What is the office name?");
    var l = field.length;
    for(var i = 0; i < l; i++)
    if(field.value==name)
    field[i].checked=true;
    field[i].focus();
    field[i].select();
    break;
    <input type="button" name="Find" value="Find And Select" onClick="findOffice(form1) >
    Thanks in advance !
    Rachel

    Thank you so much, I already solved the problem with your advice.
    You really have a beautiful mind, :-).
    I appreciate your help !
    Rachel

  • How to compare two wage types?

    What is the best way to compare two wage types?
    For example, if I see the wage type attribute screen, I need to select M010 and M110 , one by one and
    compare visually only the wt attributes. It doesn't show the processing classes etc.
    Is there a report or tool to compare and list everything about two wage types?
    Thanks,

    Thanks Arun.
    RPDLGA40 is NOT doing what I was asking. But helps a lot to learn about a given wage type.
    RPDLGA20 has many uer interactions and I am yet to learn how to understand them
    Thanks,

  • How to compare strings ignoring accents?

    Hi all,
    I'd like to know, how can I compare 2 strings, ignoring accents.
    i.e.: caf? should be come before cafo, and caf? should be considered the same word as cafe
    Message was edited by:
    Valeriano

    hint: strength
    import java.text.*;
    import java.util.*;
    public class CollatorExample {
        public static void main(String[] args) {
            test(Collator.PRIMARY, "PRIMARY");
            test(Collator.SECONDARY, "SECONDARY");
            test(Collator.TERTIARY, "TERTIARY");
            test(Collator.IDENTICAL, "IDENTICAL");
        static void test(int strength, String strengthName) {
            Collator c = Collator.getInstance(Locale.FRENCH);
            c.setStrength(strength);
            System.out.println(strengthName + " : " + c.compare("caf?", "cafe"));
    }

  • Newbie question: cannot find symbol symbol: class STRING

    I've just decided to teach myself some java, and on my first try something's going wrong and I don't know what it is.
    I'm currently doing this tutorial: http://java.sun.com/docs/books/tutorial/uiswing/learn/example1.html
    and everything is good until I try to compile it and I get this error in the cmd
    HelloWorldSwing.java:30: cannot find symbol
    cannot find symbol
    symbol: class STRING
    everything has been written verbatim from the tutorial, including "import javax.swing.*;"
    What's wrong with it and how do I fix it?

    Hi,
    I saw the coding that You had given a link in your post. Change the following
        public static void main(String[] args) {bye for now
    sat

  • UWL Guided Procedures and Substitution Rules functionality -  how possible?

    We are using Guided Procedures with Custom Web Dynpro objects and need to utilize user/role substitution that is easily enabled in other AdHoc tasks using 'Manage Substitution Rules.  Unfortunately when creating and turning ON a substitution rule in the UWL all Guided Procedure Tasks are excluded and do not show up in the substituting person's UWL.
    Does anyone have any ideas of how we can utilize Substitution Rules in UWL for all Guided Procedure tasks/steps?
    Thanks in advance
    -SteveW

    Hi SteveW!
    The situation you're facing is the normal behavior from GP in relation with substitution feature of UWL.
    Unfortunately GP doesn't support substitution as the other UWL connectors do.
    Best regards
    Armando Zaro

  • Newbie question on function pool

    Hi Abap Gurus,
    I could not locate function pool after searching in se80.
    Could you advise how function pools are found?
    Thanks in advance
    M.M

    Hi,
      Function Pool is nothing but a Function Group. So in se80 select Function group and search for the one you are looking for.
    Regards,
    Sesh

  • Newbie question with Netbeans: How do I get a component in a panel

    I've made a class called PatternComponent that extends JComponent which draws some patterns and stuff that I specify. I've been using a very basic GUI that I threw together in eclipse, but I need to clean it up and I've decided that NetBeans is more apt for the job.
    I've figured out how to get my buttons to work, but I can't find how to add my PatternComponent to the panel I want to stick it in.

    This is not a Netbeans forum.

  • How to compare string in a table reg

    Hi all,
    I need a solution of this requirement.
    i have Table reqtab
    Code sql:
    sql>select * FROM reqtab;
    REID EMAILADDRESS
    72 [email][email protected][email]
    72 [email][email protected][email]
    75 [email][email protected][email]
    75 [email][email protected][email]
    now the requirement is:
    ---> i have to create a procedure which should takes 72, 75 as in parameter
    and these procedure should compare emailaddress of 72, 75 and if this emailaddresses are not matching ,should update with unique mailids
    for 72
    i need the table should be updated in the following way
    result should be
    Code sql:
    REID EMAILADDRESS
    72 [email][email protected][email]
    72 [email][email protected][email]
    72 [email][email protected][email]
    Thanks n Regards
    Laxman

    LAX_ORA wrote:
    Hi all,
    I need a solution of this requirement.
    i have Table reqtab
    Code sql:
    sql>select * FROM reqtab;
    REID EMAILADDRESS
    72 [email][email protected][email]
    72 [email][email protected][email]
    75 [email][email protected][email]
    75 [email][email protected][email]
    now the requirement is:
    ---> i have to create a procedure which should takes 72, 75 as in parameter
    and these procedure should compare emailaddress of 72, 75 and if this emailaddresses are not matching ,should update with unique mailids
    for 72
    i need the table should be updated in the following way
    result should be
    Code sql:
    REID EMAILADDRESS
    72 [email][email protected][email]
    72 [email][email protected][email]
    72 [email][email protected][email]
    Thanks n Regards
    LaxmanYou're talking of a combination of updates and deletes to your table.
    You can define a query that can determine what action needs to be taken for each record e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 72 as reid, '[email][email protected][/email]' as emailaddress from dual union all
      2             select 72, '[email][email protected][/email]' from dual union all
      3             select 75, '[email][email protected][/email]' from dual union all
      4             select 75, '[email][email protected][/email]' from dual)
      5  --
      6  -- END OF TEST DATA
      7  --
      8      ,req as (select 72 as reid from dual union all
      9               select 75 from dual)
    10      ,mreq as (select min(reid) as reid from req)
    11  --
    12  select t.reid, t.emailaddress, case when mreq.reid = t.reid then 'No Action'
    13                                      when mreq.reid < t.reid and row_number() over (partition by t.emailaddress order by t.reid) =1 then 'Update to '||mreq.reid
    14                                 else 'Delete'
    15                                 end as action
    16  from   t       join req on (t.reid = req.reid)
    17           cross join mreq
    18* order by 2
    SQL> /
          REID EMAILADDRESS              ACTION
            72 [email][email protected][/email]  No Action
            75 [email][email protected][/email]  Delete
            72 [email][email protected][/email] No Action
            75 [email][email protected][/email]  Update to 72
    SQL>... and then action each of those as required.
    Doing it in this way, having your required REID values in a table (temporary table or whatever) will allow the query to work for any number of such values e.g. here's an example with 3 of them...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 72 as reid, '[email][email protected][/email]' as emailaddress from dual union all
      2             select 72, '[email][email protected][/email]' from dual union all
      3             select 75, '[email][email protected][/email]' from dual union all
      4             select 75, '[email][email protected][/email]' from dual union all
      5             select 77, '[email][email protected][/email]' from dual union all
      6             select 77, '[email][email protected][/email]' from dual)
      7  --
      8  -- END OF TEST DATA
      9  --
    10      ,req as (select 72 as reid from dual union all
    11               select 75 from dual union all
    12               select 77 from dual)
    13      ,mreq as (select min(reid) as reid from req)
    14  --
    15  select t.reid, t.emailaddress, case when mreq.reid = t.reid then 'No Action'
    16                                      when mreq.reid < t.reid and row_number() over (partition by t.emailaddress order by t.reid) =1 then 'Update to '||mreq.reid
    17                                 else 'Delete'
    18                                 end as action
    19  from   t       join req on (t.reid = req.reid)
    20           cross join mreq
    21* order by 2
    SQL> /
          REID EMAILADDRESS              ACTION
            72 [email][email protected][/email]  No Action
            75 [email][email protected][/email]  Delete
            77 [email][email protected][/email]  Delete
            72 [email][email protected][/email] No Action
            75 [email][email protected][/email]  Update to 72
            77 [email][email protected][/email]  Update to 72
    6 rows selected.
    SQL>

  • Newbie question for LogOn trigger and Connection String

    Hi,
    I would like to set certain session variables in the logon trigger. Is there a connection string attribute or some other way to pass a string or some data to the session.
    regards
    Stefan

    Hi,
    my concrete problem is that our application only uses one user. eg. appuser . During the login process of the application the "real" user name, language and other attributes are set in a packag as global variables.
    This works fine, but as soon as a usr logs on the DB without our application login then these are ofcourse not filled. My idea was to maybe to be able to enhance the connection string and to be able to pass some more information to the logon trigger.
    regards
    Stefan

  • Another Newbie Question, (Sigh) G5 how to open the Dvd Drive, Without an os

    Hi all as some of you will know!
    I'm pretty new to PM, and osx. Not sure what keyboard buttons to press when first booting up my system,
    Ok so heres the Deal bought a 2.0ghz and 2.5ghz powermac G5's from my work, No hard Drives so ive used a couple of 1Tb sata drives out of a couple of old pc's i have knocking about,
    1. with no opearating system on the drives how do i get the cd tray to open is their a button or key I press at startup.
    2. powered the 2.5 up and got this info (not sure what keys i hit to get this)
    User abort
    Apple Powermac 7,35.2.4.f1
    Boot Rom built on 03/25/05 at 16:41:34
    Then some other blurb about shutdown and macboot etc I typed shutdown? I take it that this is it's birthday date!
    So Guys what are the short cut keys and what do I need to know.
    These are my first ever macs and osx is totally alien to me! So while most of you guys will know this stuff off by heart  to me it's another world!
    Bye the way luving all of this! Just like my first days with the pc! Only better
    ps blasted the inside of the case's with compressed air! Man I cant believe the crap and crud that came out of them.

    OK, one of the easiest ways and probably, in a sense, the best way if you are going to install OS fresh, is to boot into Open Firmware (which you actually did as described in your post).  You can do this intentionally by holding down the cmd-option-O-F key combination until you get to the open firmware white screen.
    Then, type the following command:
    eject cd <enter>
    which will cause the optical drive tray to come out.  Drop the install disc into the tray.  Then type
    eject cd <enter>
    which will cause the tray to close.
    Then, type the next three commands to initialize NVRAM and reboot the computer.
    reset-nvram <enter>
    set-defaults <enter>
    reset-all <enter>
    Then, as it does the reboot, hold down the 'C' key which will cause the machine to try to boot from the install disc.

  • How to compare matnr based on '*'  how tocalculate subtotals via coding

    hi gurus.,
    My requirement is i hv to group all sub-partnumbers in one single part number ..
    for Example: BHRM2960 (8 chars)  is my main Part number
    for this Sub-part numbers come like this ..
             BHRM2960-010
             BHRM2960-020
             BHRM2960-030
    .. i want to group all the sub-partnumbers under main part number ..
    i.e., like this 'BHRM2960*' .. how can i achieve this ..also i have to calculate total of all the sub-part numbers based on header part number through code .. how can i achieve this.. plz help me ..its urgent ..
                         Thanks in advance

    Hi,
    use function module
    data : it_stb2    like stpox occurs 0 with header line,
           it_spma2x like it_spma2 occurs 0 with header line,
           it_matcat  like cscmat occurs 0 with header line,
    call function 'CS_BOM_EXPL_MAT_V2'
        exporting
          capid                 = 'PP01'
          datuv                 = sy-datum
          mktls                 = 'X'
          mehrs                 = 'X'
          mmory                 = '1'
          mtnrv                 = it_spma2-matnr
          werks                 = werks
        tables
          stb                   = it_stb2
          matcat                = it_matcat
        exceptions
          alt_not_found         = 1
          call_invalid          = 2
          material_not_found    = 3
          missing_authorization = 4
          no_bom_found          = 5
          no_plant_data         = 6
          no_suitable_bom_found = 7
          others                = 8.
    Regards,
    V.Balaji
    Reward if Usefull...

  • How to split string based on either space or tab delimitation?

    I'm trying to split a string into 4 fields.  The strings sometimes have space delimitation and sometimes have tab delimitation.  Is there any way to do this in a SELECT, or do I need a couple staging tables, or what?
    I'm trying to work with this.
    Select PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),4) Date,
    PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),3) ID,
    PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),2) Rank1,
    PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),1) Rank2
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    This is similar thread that someone posted a week ago
    Split delimited string into separate columns
    based on space
    My solution was, using a user defined function to split the text:
    Use Master
    Go
    CREATE FUNCTION dbo.udf_SplitString(@InputVal VARCHAR(200), @Delimiter CHAR(1))
    RETURNS @Items TABLE (RowNo TINYINT, ITEM VARCHAR(100))
    As
    BEGIN
    DECLARE @FieldLen TINYINT = 0, @FieldEnum TINYINT = 0, @TempItem VARCHAR(100) = '', @ItemLoop TINYINT = 1
    SET @FieldLen = LEN(@InputVal)
    WHILE @FieldEnum <= @FieldLen
    BEGIN
    IF (SUBSTRING(@InputVal, @FieldEnum + 1, 1) = @Delimiter OR @FieldEnum = @FieldLen) AND @TempItem <> ''
    BEGIN
    INSERT @Items (RowNo, Item)
    VALUES (@ItemLoop, LTRIM(RTRIM(@TempItem)))
    SET @TempItem = ''
    SET @ItemLoop += 1
    END
    ELSE
    BEGIN
    IF SUBSTRING(@InputVal, @FieldEnum + 1, 1) <> @Delimiter
    BEGIN
    SET @TempItem = @TempItem + SUBSTRING(@InputVal, @FieldEnum + 1, 1)
    END
    END
    SET @FieldEnum += 1
    END
    RETURN
    END
    Next, use the splited data to group based on requirements
    DECLARE @AllData TABLE
    [Column 0] VARCHAR(50)
    INSERT INTO @AllData
    VALUES('20150101 04559690 45 33')
    INSERT INTO @AllData
    VALUES('20150101 045595320 42 48')
    INSERT INTO @AllData
    VALUES('20150101 041198690 44 34')
    INSERT INTO @AllData
    VALUES('20150101 0455222130 41 49')
    INSERT INTO @AllData
    VALUES('20150101 554567450 40 51')
    ;WITH CTE
    AS
    SELECT
    ,Row_Number() OVER(PARTITION BY MainQry.[Column 0] ORDER BY MainQry.[Column 0]) As RowNo
    FROM
    @AllData As mainQry
    CROSS APPLY (SELECT Item FROM Master.dbo.udf_SplitString(REPLACE(MainQry.[Column 0], CHAR(9), ' '), ' ')) As SubQry
    SELECT
    [Column 0]
    ,MAX(CASE WHEN RowNo = 1 THEN Item ELSE '' END) AS [DATE]
    ,MAX(CASE WHEN RowNo = 2 THEN Item ELSE '' END) AS [ID]
    ,MAX(CASE WHEN RowNo = 3 THEN Item ELSE '' END) AS [Rank1]
    ,MAX(CASE WHEN RowNo = 4 THEN Item ELSE '' END) AS [Rank2]
    FROM
    CTE
    GROUP BY
    [Column 0]
    Output
    Column 0 | DATE
    | ID
    | Rank1 | Rank2
    20150101 0455222130
    41 49
    | 20150101
    | 0455222130
    | 41 | 49
    20150101 554567450
    40 51
    | 20150101
    | 554567450
    | 40 | 51
    20150101 041198690 44  34
    | 20150101
    | 041198690
    | 44 | 34
    20150101 045595320 42   48
    | 20150101
    | 045595320
    | 42 | 48
    20150101 04559690 45  33
    | 20150101
    | 04559690 | 45
    | 33
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • How to extract substring from a string based on the condition ??

    Hi,
    I'm having a very large string which as below
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD'
    FTX+AAA+++ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND'
    FTX+AAA+++IS FAIR'
    similarly FTX+AAA as above and it goes on
    i tokenized each segment with delimiter as ' and able to read each segment.
    Now i want to concatenate the FTX+AAA in a single segment if more than one FTX+AAA with IMMEDIATE below
    The output is as follows
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD,ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND,IS FAIR'
    similarly FTX+AAA should be concatenated if it has similar FTX+AAA IMMEDIATE below.
    The FTX+AAA segments can come any number of times immediate below
    Please help me how we can do this??? Can anyone help me with the code snippet to do this?
    Thanks,
    Kathir

    Encephalopathic wrote:
    You've posted > 300 times here and you still don't respect the rule regarding notification of all cross-posts? [http://www.java-forums.org/advanced-java/30061-how-extract-substring-string-based-condition.html]
    Do you think this this will help convince others to help you?See also [http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition|http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition].

  • Newb Question for burning DVD/CDs

    I have an external DVD writer on my iMac.
    I got the thing last month and an completely new to Apple (sorta)
    Now how do I make a data CD and DVD?
    On Winblows XP all I need to do is select the files, right click and click on SEND FILES TO CD for making data CDs.
    However for DVD I need 3rd party software.
    Will iDVD do the trick?
    Thanks for the looking at this simple newb question.
    GeekyBoy

    Now how do I make a data CD and
    DVD?Drag the files to the icon of the
    blank CD/DVD that appears in the
    Finder.However for DVD I need 3rd party
    software.You might want to try Patc
    hBurn.Will iDVD do the
    trick?No, iDVD is only for making video
    DVDs and it requires a G4 processor.
    Thanks for the tip Duane.
    I was just reading abotu burning CD on another site. It mentions about what you said, drag the files to the CD.
    However I am reading in my profiler that burning is NOT supported by OS X on this CD/DVD writer.
    Will Patchburn or any other software overcome this?
    Thanks

Maybe you are looking for

  • Multiple issues with iTunes Sharing. Help?

    I have a Mac mini running 10.6.8 with iTunes 11.0.2 (and all other updates) connected to my living room television. I use it as a storage/playback system for my movie collection and a small amount of MP3s (about 250). This evening I decided to enable

  • MacPro 2,1 apparently rebooting itself in the night?

    Hey everyone, I have a Mac Pro 2,1 running Snow Leopard (10.6.8) and almost daily, when I wake it up from sleep it acts like it has rebooted itself at some point during the night (login items showing). I do have it set to wake on LAN, and going back

  • Annoyed by OTN username and password prompting

    Sorry it's really starting to annoy me that I always have to enter my OTN username and password between every browser session. Why can it not use a cockie or whatever to keep me logged in at least for the day. Or better, let me save the password in m

  • How to specify the database file path when create FDM application

    Dear All, How to specify the database file path (MSSQL) when create FDM application? Right now, all data file are placed in the D:\ . I want to specify the database files (log and mdf file) in other place. How to do it? Thanks.

  • Error using TABLES

    I am using Logical database PNPCE in HR for my report. To get the selection screen of the LDB in my report program i need to give the statement TABLES : PERNR. But using this is giving me EPC error that TABLES should not be used. If i take out TABLES