Replace a string in the data of the element - OSB / Xquery

I want to replace a string in a piece of XML data in OSB/XQuery. Pls help me... (by something in the XPATH expression or actions of the OSB)

Scenario looks like - I want to remove "IND_" of the field type in the code xml.

Input XML (OSB or XQuery) - stored in a variable say $cricInfo

< CricInfo >
< player >
< drive >
Sachin < name > < / name >
* < Type > IND_BAT < / name >. *
< / player >
< drive >
Barouk < name > < / name >
< Type > IND_BOWL < / name >
< / player >
< drive >
Dhoni < name > < / name >
WK of < type > < / name >
< / player >
< / players >
< / CricInfo >

Output XML file

< CricInfo >
< player >
< drive >
Sachin < name > < / name >
< * type > BAT < / name >. *
< / player >
< drive >
Barouk < name > < / name >
BOWL of < type > < / name >
< / player >
< drive >
Dhoni < name > < / name >
WK of < type > < / name >
< / player >
< / players >
< / CricInfo >

Best regards, Sesha

may also adapt the 'identity Transform' to do some filtering on the item 'type ':

Here the transformation of base:

http://en.Wikipedia.org/wiki/Identity_transform#Using_XQuery

at least you would avoid having to reproduce the overall structure of the document in your XQuery, which is always a Bad Thing (TM)...

by the way, your XML file is not well formed, I fixed it here


Sachin
IND_BAT


Barro
IND_BOWL


Dhoni
WK


Tags: Fusion Middleware

Similar Questions

  • Replace the string with the formatted text

    Hello all - I'm back to my beloved project...

    I want to replace a string by a TextSelction (formatted text) and began with the famous feature of Jang FindAndReplaceString.
    Since my replacement comes from another document (sourceDoc), I edited to targetDoc activeDoc and introduced a second document (sourceDoc).
    The replacePara actually comes from a stone where he had been placed to avoid switch backwards between the documents in a book (where to find and replace) and source documents. In another function, I learned that information on the table requires the sourceDoc must remain open.

    • Of course, everything works fine until I want to insert the replacelement:
      erase line 26 is the string
    • Given that I do not insert a string, I skip lines 28 and 29 and try try line 30
    • On line 30 DocumentSource is Document object and replacePare object TextSelection. However, sourceDoc.replacePara is not set and
    • (as a result?) line 31 past the current contents of the Clipboard.

    Of course, there is a fog around me... and I need some sunshine.

    function FindAndReplacePara (targetDoc, findString, sourceDoc, replacePara, loopMax) {
      var tr = new TextRange();
      var restoreTR, frame = 0, loopCounter = 0, replacementCounter = 0;
      var findParams = new PropVals();
      var firstPgf = targetDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
      
      tr.beg.obj = tr.end.obj = firstPgf;             //  set up the starting text range as the very beginning
      tr.beg.offset = tr.end.offset = 0;              // of the flow. We'll move straight from beginning to end.
      trSaved = tr                                    // to come back after work
    
      findParams = AllocatePropVals(2);
      
      findParams[0].propIdent.num = Constants.FS_FindText;
      findParams[0].propVal.valType = Constants.FT_String;
      findParams[0].propVal.sval = findString;
      
      findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags;
      findParams[1].propVal.valType = Constants.FT_Integer;
      findParams[1].propVal.ival = Constants.FF_FIND_CONSIDER_CASE;
    
      FA_errno = Constants.FE_Success;                // errno global, to be used to track the progress of the find and replace
      tr = targetDoc.Find(tr.beg, findParams);        // and do an initial find to get started.
      
      while(FA_errno === Constants.FE_Success && loopCounter++ < 2*loopMax) { //find and replace loop as long as we keep finding
        targetDoc.TextSelection = tr;                 // set up the text range to clear the original text
        targetDoc.Clear(0);                           // clear it
        
    //    targetDoc.AddText(tr.beg, replacePara);       // insert the new text at the original beginning of the text range
    //    tr.beg.offset += replacePara.length;          //  lets jimmy the text range in memory to place it directly after
        targetDoc.TextSelection = sourceDoc.replacePara;        // paste the whole replacement paragraph
        targetDoc.Paste (0);                          // <-- Current contents of clipboard is pasted !!!!
        if(FA_errno === Constants.FE_Success) {       // increment our return counter
          replacementCounter++;
        }
        FA_errno = Constants.FE_Success;              // ...  find the next instance. We'll reset FA_errno again just in case
        tr = targetDoc.Find(tr.beg, findParams);      // something screwy happened while we were replacing text.
      }
      targetDoc.ScrollToText(trSaved);                // we're done. Restore the document to it's original area of display
      return replacementCounter;
    } // --- end FindAndReplacePara
    

    Hi Klaus,

    Thanks for the explanation. I remember something like that GetTabRange of the way back. You have been quite patient and persistent with this project, indeed.

    So, as we are dealing with ranges of text here, I think that the only simple approach is to perform a copy and paste. There is no way to save a 'formatted' in a variable. The only super precise way would be to get a data structure of each text range TextItems in the sourceDoc, then meticulously recreate every element of the targetDoc. It would be very complicated, I think, so copy and paste seems the most logical. I wonder, though, if Miss me something, because I think that maybe you would have tried already so yes (?)

    In any case, I would do something like that, from line 30 of your original code sample (code untested here):

    App. ActiveDoc = sourceDoc;

    sourceDoc.TextSelection = replacePara;

    sourceDoc.Copy (0);

    App. ActiveDoc = targetDoc;

    targetDoc.Paste (0);

    ... etc.

    Does make sense, or am I barking the wrong tree, as they say?

    Russ

  • Regex to replace all occurrences of an empty string, except the last

    Hello, everyone!

    I need get to a regular expression to replace all occurrences of an empty string except the last. Right now I'm doing this with this code:
    public static void main(String[] args)
    {
        String str = "abc";
        String regex = "";
        System.out.println(str.replaceAll(regex, "-").replaceFirst("-$", "")); // -a-b-c
    }
    As you can see, to do this, I have to make two calls: one for replaceAll and another for replaceFirst to get rid of the last character. So I would like to get rid of the call to replaceFirst and have the variable of regex as being a regular expression that would be to insert the character along the chain of all but the last. I'm really not very good with regexs, so I ask your help here. The thing I work, but I think it would be more elegant with just a regex to do.

    Thank you in advance.

    Marcos

    Try this:

    String data = "abc";
    System.out.println(data.replaceAll(".", "-$0"));
    
  • I want to write data of type string in the 2D table outside. How can I do?

    I want to write data of type string in the table outside. How can I do? Help me please!

    Could you explain your question more clearly, including a photo showing what you're trying to do?  I don't understand what you want.

  • SQL DEVELOPER DATA MODELER tables seem to be read-only and make it a symbol of the string in the upper left corner

    I have a lot of tables in my data model.  I have three relational models defined in this file.  In one of the models, all tables seem to be read-only.  They all have a string in the upper left corner of the box.

    I use version control, so that are not archived or something like that.

    How to unlock these items?  Why they seem to be locked?

    Thank you

    Must not have been involuntary - you should have physically moved and dropped the tables/entities from one model to the other.

    If you want to copy them and be able to change in the future, use instead of copy / paste.

  • Help for a date and time string in the format of get-date

    When you take a date / time string of an object:

    The format of the entry is a string and get-date doesn't seem to be able to convert to the

    a System.DateTime.

    I want to compare this value to 30 days so there are get-date ((get-date).adddays(-30))

    When I try the following, it seems to work then import it:

    (get-date - UFormat "%d/%m/%Y %T" ("2010-06-30 00:00:00" ""))

    If I add the following:

    "[datetime]" (get-date - UFormat "%d/%m/%Y %T" ("2010-06-30 00:00:00" ""))

    He can't convert it.

    Without the datetime component, when I try a superior test uses only the date

    the part as well:

    $Test = '2009-10-06 00:00:00.

    If ($Test - gt (get-date - UFormat "%T"("06/05/2010 00:00:00") %d/%m/%Y ""))

    {

    $Tested = 'Yes '.

    }

    On the other

    {

    $Tested = 'no '.

    }

    $tested

    Results in a Yes tentatives being earlier.

    In the script it returns all records where the date is after

    as 05 and ignore the year, month, and time.

    Any help with this would be greatly appreciated.

    Thank you

    This has to do with the 'culture' that you use in your PowerShell session.

    You can use the Get-Culture cmdlet to see that one you use.

    If you try

    [datetime](get-date -UFormat "%m/%d/%Y %T"("30/06/2010 00:00:00"))
    

    The parameter - UFormat produces a string and

    the cast is expected default mm/dd/yyyy format, for the part of the date.

    So, by reversing the month and day of your UFormat string - that has been corrected.

    BTW, I have attached the line because the SW forum do not have hooks.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Label String to the data shared send event

    Well, I'm in trouble. I want to click a button (a label to be exact).

    So I have my label

    I've got and event listener for the label, click

    And now I want to take the text of the label string and use it in an event to send while sending a page change event (2 events shipping both to the 2nd page)

    On this second page that I need to know what the chain of the button pressed was so I can still process events.

    Basically, it's my event flow:

    • Click on the button
    • Send event (the signal to open second page)
    • Send event (shipment in the chain) (which I can't find out how)
    • See the second page
    • Dynamically load information based on the button pressed on the first page (which I know how to do, I just need to know how to get that String of the button that was pressed)

    I have all work perfect with the exception of the dilemma of channel button. There will be a lot of buttons (rather labels) involved.

    Each event has a 'target' attribute  The target is the object originally shipped from the event.  For example, a LabelButton dispatches a click event, you can cast the target to this object to know things about this target (assuming that the target is always in memory).

    private void ButtonClicked (event: Event): void

    {

    trace (LabelButton (event.target) .label + "button");

    }

    If you pass an intermediate event and you want to carry information at this event, you can create your own event class by extending the event base class and adding the attributes that you want to carry.  You can also watch the event meta class that allows you to attach some meta information with the event class that they prepare.

  • Incorporate the binary string in the string spreadsheet file

    Hello LabVIEW wizards...

    So I use scripture to VI file spreadsheet to create a beautiful layout, tabs-delimited report of one of my programs for the acquisition of data file. In one of the cells in the resulting worksheet file that I want to put a binary string of all my control values so when you open the data file all the control parameters used for its manufacture are restored, but the string is hidden when the report is displayed in Excel.

    The problem is that the binary string flattened uses tabs and returns as part of its syntax the Spreadsheet File this VI to Write it's going in all directions. Worse yet, I can't unflatten chain when I open the file text because of "corrupt data or unexpected".

    If I concatenate the string flattened with quotes around it she is superb and is placed in a single cell in Excel, but when I open the file in LabVIEW that she is still several elements in the array. I've isolated the binary string using the file VI text reading and got a subset of the quoted string, but it still unflatten correctly.

    Essentially, I need to know how to get LabVIEW to pull a string literal full of special characters into a spreadsheet file and it unflatten. Any gurus what help you can provide is greatly appreciated.

    Thank you

    Jordan

    Jordan

    I suggest that you change the formatting of your chain shipped by replacing the tabs and returns with other characters that are not considered as commands by the spreadsheet functions. Without knowing how you represent your control binary values, I can't offer specific characters.

    If two non-printable characters exist which do not appear in the control data, it's easy: just find and replace tabs and returns with those characters.  If there is no character, then something more complex needs to be done for example to escape special characters.  Or create two subVIs - one to remove the tabs and returns before writing the string in the file and the other to restore after reading.

    Lynn

  • Input string in the text through business rule beam

    Hello, I have a problem I can not enter a string in the text bar using the equation like membername = 'chain' or % membername % = @alias("January"); He entered nothing in the cell or replaces the existing value with #missing, on the other hand I can enter numbers here, but essbase interpreter number to a string. like 1 = Andy

    Essbase can store only numerical data and business rules are run on the essbase database.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Formatted string in the Workbench

    Hi all

    I'm on LC 8.2 and the database is SQL Server.  My requirement is: I need to send emails to a process to all members of a particular group of users.  As much as I know there is no functionality in workbench that helps me do that.  I therefore e-mail ID of the database.

    Here's my query:

    SELECT ',' + prin.email
    From edcprincipalentity AS main,.
    edcprincipalgrpctmntenti AS gr
    WHERE prin.id = gr.refchildprincipalid
    AND refparentprincipalid = (SELECT id FROM edcprincipalentity lcuser
    WHERE lcuser.principaltype = 'GROUP '.
    AND lcuser.commonname = "< GroupName >")

    And the result will be like this:

    , [email protected]

    , [email protected]

    , [email protected]

    I use 'Query for multiple lines in XML', to query the database.  Now, I need to convert it to a string of plan containing email ID inorder to use in the control of the Email.

    I use SetValue executes control to convert that.  I have a string variable in which I put the string value of the xml using serializable.

    /process_data/@EmailIds = serialize(/process_data/EmailIdsFromDB)

    It gives me the chain EmailIds = ",[email protected] [email protected] [email protected]" " " ".

    Now my problem is I can not use the result directly on my Email control because it contains a comma.  I have to remove this one somehow.

    /process_data/@EmailIds = substring (/process_data/@EmailIds, 2)

    But I do not get the desired result.

    Can someone help out me or suggest me another method to do this?

    Thank you

    Deepak

    Ok

    Let's try a different approach.

    You have your xml data in an xml variable right?

    Why not just use a setValue with an xPath expression to get the value of all the nodes.

    You can get the number using the following xPath expression: count(/process_data/xmlvar/Email/EmailId)

    Then, to set a counter variable I (integer data type) to the value of count.

    Then, wrap and increment the counter and the build you string using the XPath following

    /process_data/@strlist = concat (/process_data/@strList,/process_data/xmlvar/Email/EmailId, [process_data/@i], /mailId)

    You may need to replace process_data/@i by number (process_data/@i) for the xPath expression work correctly.

    Jasmine

  • string in the format spreadsheet in table: Missing comma

    Hi all

    Plug-in function "string in the format spreadsheet en table" with LabVIEW 2014. I do not understand why, but the point numbers are truncated at the output of the function.

    This is the VI as an attachment.

    Thanks for your help!

    Hello

    The decimal separator of your OS comma an EST. So either you replace it with a point or you replace the %f in your code by %; % f:.

  • Array of strings in the container will not pass in an array of strings in LabVIEW cluster

    I'm new to TestStand, but I'm a CLD.  I took a course custom 3 days which covered most of the TestStand Core 1 and some of the Core 2.  I use TestStand 2013 and 2013 of LabVIEW.

    I have a VI that needs a supply of a cluster that contains, in the following order:

    D 1 string array named Column_Labels

    Table 2D-double named Results_Data

    D 1 table of paths named Graphics_File_Paths

    D 1 table of Boolean named Pass_Fail

    I created a custom data type called Maxim_Results from the tab module VI in the TestStand sequence.  When I have a local (MINSYS_Reuslts), which is made from this Type of reference, I get the following error:

    No corresponding subproperty to the 'Locals.MINSYS_Results' of type 'Maxim_Results' argument for the element "Maxim_Results.Column_Labels" of the cluster

    If, however, I make reference to each item container for each item separately cluster there is no error:

    Can someone help me understand why this is happening?

    Hey Kelly,

    I just implemented the situation you described and it worked correctly for me. However, I noticed that in your example where you have referenced each element individually, your element Column_Labels is actually called "Column_Lables". If it was also misspelled in the LabVIEW Cluster parameter from the custom type, he practiced the behavior you're seeing. This could possibly be the case?

  • Length of the string, excluding the input character/string

    Long story short, I want to replicate the function of the length of the string , but do not include an input the number of characters in string. For example:

    The input string (search) is 'the

    My first string to test is "the big red dog."

    That would mean a 13 string length.

    My second string is "Jumps over the lazy Fox."

    That would mean a length of 21.

    ' Hello World! ' would return 12.

    'The Lion, the Witch and the wardrobe' would return 26.

    I hope that you can see what I want to achieve. How is this possible?

    -James

    (I'm driving Labview 8.5)

    Use the search and replace the string to replace your 'exclusive' with an empty string string.  Use the length of the string on the result string.  Make sure that everything is already set to TRUE.

  • Look for the string of the numbered array element.

    This is my first post, so I'll probably miss one thing or another.  I will look nothing missed as soon as possible. I write code LV to test additional County stored in a CSV text file. Counties represent the stimulated current of a diode in a beam of radiation. The product is a QA device for a medical radiation treatment machine. The Integrator output proportional to the current diode accumulates as a whole into account in the text file. My LV code puts the numbers in the tables, calculates the incremental time derived and analyzed statistically. Numbers of the columns in the table data represent unique components. Default number of data column is sorted in a 1 d table has no column number. As if not column 10 represents CR39 of PCB 11. I need an algorithm how to connect a string such as CR39-PCB11 to the element of the array 1 d failure or relate to the string to the column in the data table that fails. Could you suggest a way to do this?

    If I understand you correctly, instead of these numbers that are in the Updates (odd) 'zero', you want to get premium channels. For the moment, the operator uses a lookup table, to find the chain (component) that corresponds to the column number.

    It's easy, because you only need an array of strings (corresponding to the column number 0 n) and use the array index with the index of the column. Place it in a loop for get all the clues of failures (the loop autoindexing for).

    Felix

  • Loading of the DLL string using the Code Library function node

    I experience now with the element of Code Library function node... what I wanted to do are, for example, I have compiled a. DLL file... which has a function that returns the pointer to string... function looks like:

    / * This function returns a pointer to the character string * /.

    char * pchar (int n)

    {

    char * str [] = {"error", "String1" and "Word2", "3"};

    Return ((n! = 1) & (n! = 2) & (n! = 3))? Str [0]: str [n];

    }

    but when I load into LabView DLL, a part of the chain on the screens to Panel frontal trash... any ideas why?

    p.s. when I do even with integer values... say my job is like int x = 5; Return x; and then I load in LabView to the digital indicator... it works great!

    So any ideas?

    thanx

    Cyrax says:

    I experience now with the element of Code Library function node... what I wanted to do are, for example, I have compiled a. DLL file... which has a function that returns the pointer to string... function looks like:

    / * This function returns a pointer to the character string * /.

    char * pchar (int n)

    {

    char * str [] = {"error", "String1" and "Word2", "3"};

    Return ((n! = 1) & (n! = 2) & (n! = 3))? Str [0]: str [n];

    }

    but when I load into LabView DLL, a part of the chain on the screens to Panel frontal trash... any ideas why?

    p.s. when I do even with integer values... say my job is like int x = 5; Return x; and then I load in LabView to the digital indicator... it works great!

    So any ideas?

    thanx

    You cannot return a pointer to the data stored on the stack. At the time when the function returns, the stack is reset to the State before the call to the function and in a multithreaded as LabVIEW environment probably long reused for other things when LabVIEW gets around to actually copy the returned pointer data.

    Since it is a read-only variable, you could create a permanent memory for string storage by declaring your variable static. This will create a memory area allocated globally for the string data (and also cause a compile error when you try to write in this area somewhere in your code, which is a good thing).

Maybe you are looking for

  • Qosmio G30-117 - no HDMI plug - so, how can I connect to my new TV HDMI

    HelloI've had this laptop for about a year and for a large part of which I had no idea what was HDMI. Then my old TV died and I had to get a new one. In order to have my Qosmio I assumed (stupidly) - after all, it is a (relatively) new piece of equip

  • What is the problem with Safari?

    Since the last update of El Capitan, Safari has become almost worthless.  I can't use it. It will give me the beach whirling death ball. I can not click through links. the full page is not displayed. What the * is the problem with that?  It's the kin

  • Downgrade from Vista woes (a6042n)

    Today, I went down my HP Pavilion a6042n for XP desktop computer. Lost PC recognition/drivers for audio AND networking. In Device Manager, there are a few items that have a yellow question mark by them. Fortunately, I have an old HP 8580c that barely

  • My HP MediaSmart programs work not at all

    Even the touchbutton mentioned does not work; my webcam is not no longer works. When I click on it, looking in my programs, they don't appear. Just the hourglass icon, but it subsides quickly. Nothing happens then. Does anyone know what is the proble

  • Change in Windows update update

    I am logged in as administrator.  However, windows update States that the disabled administrator updates in last July.  There seems to be no way to change this setting.  What should I do?