XSLT for dynamic target field names

Hello,
I got a requiremt where I need to create target field names from input values.
Input XML -
<?xml version="1.0" encoding="UTF-8"?>
<Createelement_MT>
<Field Name="A">
<Value>1</Value>
</Field>
<Field Name="B">
<Value>1</Value>
</Field>
</Createelement_MT>
Expected OutPut XML -
<?xml version="1.0" encoding="UTF-8"?>
<Createelement_MT>
<Statement><TableName><table>XYZ</table>
<access>
<A> 1 </A>
<B> 2 </B>
</access>
</Statement></TableName>
</Createelement_MT>
The value of the attribute 'Name' of field 'Field' should be the name of target field.
XSLT:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Createelement_MT">
<xsl:element name="statement">
<xsl:element name="TableName">
<xsl:element name="table">ABC</xsl:element>
<xsl:element name="access">
<xsl:for-each select="Field">
<xsl:element name="{@Name}">
<xsl:value-of select="Value"></xsl:value-of></xsl:element></xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Error:
Error: at xsl:element on line 15 of file:///......: XTDE0820: Invalid element name. Invalid QName {}
Please help me with the xslt code for this requirement.
Thanks!

Hi,
            Please try this code
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="xml"/>
     <xsl:template match="/">
          <Createelement_MT>
               <Statement>
                    <TableName>
                         <table>XYZ</table>
                    <access>
                         <xsl:for-each select="Createelement_MT/Field">
                              <xsl:variable name="field" select="@Name"></xsl:variable>
                              <xsl:element name="{$field}">
                              <xsl:value-of select="Value"></xsl:value-of>
                              </xsl:element>
                         </xsl:for-each>
                    </access>
                    </TableName>
               </Statement>
          </Createelement_MT>
     </xsl:template>
</xsl:stylesheet>
input xml
<?xml version="1.0" encoding="UTF-8" ?>
- <Createelement_MT>
- <Field Name="A">
  <Value>1</Value>
  </Field>
- <Field Name="B">
  <Value>1</Value>
  </Field>
  </Createelement_MT>
output xml
<?xml version="1.0" encoding="UTF-8" ?>
- <Createelement_MT>
- <Statement>
- <TableName>
  <table>XYZ</table>
- <access>
  <A>1</A>
  <B>1</B>
  </access>
  </TableName>
  </Statement>
  </Createelement_MT>
One small request, if you think your question has been answered,could you please kindly, if possible, close this thread.
regards
Anupam

Similar Messages

  • Message-Mapping: Use same RFC lookup for different target fields

    Hello,
    I need to apply an RFC Lookup which delivers a boolean flag back (true or false). This RFC lookup should be used for different target fields.
    Is there a way to execute the RFC lookup just once and then store the result in an internediate variable that I can use for all futher checks for different target fields?
    If this is not possible and I have to apply the RFC lookup for all necessary target fields is it then executed for each target field ? This is exactly what I want to avoid in order not to slow down performance.
    The input parameter (=source field value) would be the same.
    Thank you for your advice!

    Exactly.
    Here is a UDF example I have that you could adapt to your needs.
    Set
    public String setCounter(String a,String b,Container container){
    /* Store values in global datacontainer
    a: mapping value and return valueparameter
    b: name for stored value parameter
    GlobalContainer myGlobalContainer;
    myGlobalContainer = container.getGlobalContainer();
    myGlobalContainer.setParameter(b.toUpperCase(), a);
    return a;
    Get
    public String getCounter(String a,Container container){
       //write your code here
    GlobalContainer gc = container.getGlobalContainer();
    if (gc.getParameter(a) != null) {
      return String.valueOf(gc.getParameter(a));
    } else {
    return "1";

  • HR - dynamic selections field name and field value in the program

    HI all,
       I am using dynamic selections for a HR report.
    I have created a view with 20 fields and added it to HR report category ___00003(All fields suppressed).
    I need to check these fields in the program. But i am not able to get the field name and value in the program for dynamic selections fields.
    Please let me know how to get the field names and values in the program for dynamic selections .
    Thanks,
    Kranthi.

    You have to read the itab <i>pnpdynse</i> in your Program to obtain the Dynamic Selection values. This itab has a deep structure.. you can set a break point in one of the events before <b>get pernr</b> & in the debug mode, you will able to display the itab <i>pnpdynse</i>.. you can then identify how to get the values into your code..
    ~Suresh

  • If else conditional statements for dynamic text fields (as 2.0)

    This is about a self assesment quiz.There will be four options and each one has a scale from1-5 ie "option a" has 1mark, "option b" has 2marks,"option c" has 3 marks, "option d" has 4marks and "option e" has 5 marks and we count the answerd and we display the scor for example if there are 20 question in it if they answered "option e" 5 times the score will be
    25 and option d 5 times the score will be 20,anf if "option c" for 5 times the score will be 15,and "option b" for 3 times  the score will be 6 and "option a" two times the score will be 2, and we add up all the score and display in a dynamic text field called "scor" and the total score is 68.And i have another dynamic text field called "tsc" where i have to display the tags like excellent , good, better ......ect.
    Till now every thing is fine but i am unable to compare them it is displaying excellent even if i get 10 marks, i am unable to configure where i am going wrong.
    If the score is greater than 55 "tsc" should display Excellent, if the score is greater than 41 or less than 55 "tsc" should display Best, if the score is greater than 26 or less than 40 "tsc" should display Better,if the score is none of the above "tsc" should display Poor.
    This is my code on the submit button:
    on (release) {
        gotoAndStop("sQ");
        if (scor>=55) {
            tsc = "Excellent";
        } else if (scor == 41 && scor<=55) {
            tsc = "Best";
        } else if (scor == 26 && scor<=40) {
            tsc = "Better";
        } else if (scor == 10 && scor<=25) {
            tsc = "Good";
        } else {
            tsc = "Poor";
    where:
    "sQ" is the frame name where i am displaying the score details
    "scor" is the var name for the dynamic text field for displaying total score
    "tsc" is the var name for the dynamic text field for displaying the tags llike good, Excellent, better, poor.....etc
    Plese help.......

    Use trace commands to make sure that what you think you are processing is what is actually hapenning.
    Your middle conditionals are not written as you described them... any "==" should be ">="
    It is recommended you get away from using the textfield var option... it can be troublesome to work with.  Just assign an instance name to the textfield and assign the values to its text property... for instance, say you name it tscField, then you would use tscField.text = "Excellent";
    Also, realize that the gotoAndStop command will not happen until after all the code executes in case that matters
    on (release) {
        gotoAndStop("sQ");
        trace(scor);
        if (scor>=55) {
            tsc = "Excellent";
        } else if (scor >= 41 && scor<=55) {
            tsc = "Best";
        } else if (scor >= 26 && scor<=40) {
            tsc = "Better";
        } else if (scor >= 10 && scor<=25) {
            tsc = "Good";
        } else {
            tsc = "Poor";

  • How to dynamically list field names

    Hello,
    I have a DB Link to a SQL 2000 Server and can connect and retrieve using Heterogenous Servives.
    Let say I issued a Select (eg., Select * from tab@remote1), how do I dynamically list each field name from the result?
    Thank you.

    The best way to deal with dynamic column names from a SQL result is to use a cursor describe interface.
    A SQL SELECT may not select all the columns from a table. It may join tables. It may add derived and calculated columns to the result.
    None of these will be seen when using the data dictionary. Also, using a remote heterogeneous data dictionary? That does not sound like a sensible approach to me.
    In PL/SQL, one can create DBMS_SQL cursors. These cursors can be "described" - i.e. the describe interface for a cursor tells you what the contents are, the column names, the data types, the precision, etc.
    Using DBMS_SQL allows you to describe any result set from any SELECT statememt. A far superior and accurate method than to go data dictionary hunting to determine just which column could be in a result set.

  • Evaluating dynamically generatedform  field names

    On form submission I need to find out if check boxes exist
    and have values. The field names are generated dynamically &
    there could be many. Here's the code I've been messing with. I am
    able to find out it the field has a value if it exists, but I can't
    figure out how to combine this with isDefined("") to test for the
    field's existence and avoid the "field i not defined in form"
    errors.
    <cfloop index="a" from="1" to="#form.numRows#">
    <cfset thisname = "form." & #a# & "_Clear">
    <!--- how do I use isDefined("") at this point to avoid
    an error on the next line when the field does not exist? --->
    <cfset thisVal= Evaluate("form.#thisname#")>
    <cfoutput> #thisname# #thisVal# </cfoutput>
    </cfloop>
    Thanks in advance for any help!

    run a loop over your field names like: <cfloop index="x"
    list="#form.fieldnames#"> then you have all of your form field
    names that are defined.

  • Master  table for RFQ(Request For Quotation). Field name is RFQ

    hi,
    I need to know the master table for RFQ(Request For Quotation) number . The field name is ANFNR . In the T.code ME42, i found that it is using the structure RM06E. But i need to know its corresponding master table

    the table EKKO (EKPO Items table) and you can find the Quote number in EBELN field. Don't go by the structure / field name on the screen
    Forgot to metnion that you need to use the right document category and the document type.
    Regards,
    Ravi
    Note : Please mark the helpful answers
    Message was edited by: Ravikumar Allampallam

  • Table for description of field name.

    Hi,
    Want to know is there any single table which stores all the Technical field names used in SAP Vs Description of these fields...?
    Like WERKS = PLANT.
    This doubt has come because there is table "TSTC" for" T. codes". Similarly, there may be table for field description as well, is my opinion.
    Thanks & Regards,
    Siva

    Hi
    From the field you need to indentify the domain in se11, then you can goto se16, table name is DD01T
    DOMNAME = domain name
    DDLANGUAGE = language
    you can Identify the text
    For table short texts you can refer table - DD02T
    Thanks !
    E.Avudaiappan

  • 6 IF-THEN and OR conditions for one target field mapping

    Hi Mapping experts,
    I have a validation condition involving 2 source fields and 1 target field only, however the number of conditions is 6 (OR)
    Source Fields:
    TYPE
    PONUM
    Target Field:
    BELNR
    If TYPE = 1st value   then   BELNR = PONUM substring (0, 8)  0=start position, 8=character count
    OR
    If TYPE = 2nd value   then   BELNR = PONUM substring (2, 8)
    OR
    if TYPE = 3rd value  then  BELNR = PONUM substring (4, 8) ..........  up to the 6th Validation Condition.
    When I do this using graphical mapping only (multiple IF-THEN and OR's) the validation is successful only on the 1st IF-THEN statement, then it passes the substringed value to the 1st OR function.....    When I "Display Queue" the 1st OR function the substringed value is taken as null (or:in1 <null>)  Is this because OR function is expecting Input as "True or False" value only and not a string value?
    For my requirement above, can I achieve this using graphical mapping only?    or do I have to use UDF for this?
    If it's better to use UDF for this, would anyone give me a jumpstart on the code?  (I have no experience yet in UDFs)
    Thanks, and hoping that somebody will respond accurately and completely.

    Create UDF with two inputs as TYPE & PONUM and use bleow code there..
    String out = "";
    if( TYPE.equals("1"))
    out = PONUM.substring(0,8);
    return out;
    else if( TYPE.equals("2"))
    out = PONUM.substring (2,8);
    return out;
    else if( TYPE.equals("3"))
    out = PONUM.substring (4,8);
    return out;
    else if( TYPE.equals("4"))
    out = PONUM.substring (4,8);
    return out;
    else if( TYPE.equals("5"))
    out = PONUM.substring (4,8);
    return out;
    else if( TYPE.equals("6"))
    out = PONUM.substring (4,8);
    return out;
    return "";
    Note: change the substring range as per your need in above code.
    Now do your mapping as shown below
    TYPE ------>|
                | -----> UDF ---> BELNR
    PONUM----->|

  • Please help with dynamic form field names in cfloop

    Hi,
    I need to create a form with day, date, month, year and time for 12 months
    Instead of coding them 12 times, I create day,date,month,year and time fileds in my form 1 time and then I use cfloop from="1" to="12" index="i" to loop these form fields 12 times.
    I gave each form field name such as: <input type="text" name="ScheduleDate_# i #" value=" "> this way each of those field will be named differently such as:
    ScheduleDate_1, ScheduleDate_2,ScheduleDate_3, ScheduleTime_1,ScheduleTime_2, etc
    I'm facing problem when this form is submitted, I think the error has something to do with the pound sign (##) when it comes to updating the back end
    I use MS SQL
    It doesn like this:
    <CFLOOP From="1" To="12" index="k">
    <CFIF Len(Trim(Form.MeetYear_#k#)) NEQ 0 AND Len(Trim(Form.MeetTime_#k#)) NEQ 0>
    <cfquery name="CreateSchedule" datasource="#DSN#">
    UPDATE TableSchedule 
    SET SchedDay = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedDay_#k##">,SchedMonth =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedMonth_#k##">,SchedDate =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedDate_#k##">,SchedYear =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedYear_#k##">,SchedTime =
    <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SchedTime_#k##">
    Where SchedId = <cfqueryparam cfsqltype="cf_sql_numeric" value="#k#">  
    </cfquery>
    </CFIF>
    </CFLOOP>
    Can anyone help please?

    You can't nest hash marks. Do this instead:
    SET SchedDay = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form["SchedDay_" & k]#">
    Dave Watts, CTO, Fig Leaf Software
    http://www.figleaf.com/
    http://training.figleaf.com/

  • Bind.ref not working for dynamically added fields

    I am working on a template that has a table with rows added at the run time. I have to attach fields in each row to an XML tag and child tags. I am using SOM Expression to identify each field in the run time. I have written the code to go in a loop and bind the field at run time but it was not working. So I am just kind of trying out for binding one field using the SOM Expression.
    This code was written in the initialize event of the TextField2 with Java Script as the scripting language.
    var fieldPath = xfa.resolveNode("xfa[0].template[0].Message[0].Page1[0].Table1[0].Row1[" + 0  +"].TextField2[0]");
    fieldPath.bind.ref = "$record.COMMAND.sendApplicationInformationRequest.formNumber";
    xfa.form.remerge;
    I also tried by changing the reference this way but no luck..
    var fieldPath = xfa.resolveNode("xfa.template.Message.Page1.Table1.Row1[" + 0+ "].TextField2");
    Can any one help on this?
    Thank you
    Srini

    Hi Steve,
         Thank you for your response..
         I could not able to open your attachments.. They both say QUEUED..
    dynamic-subform-with-data-binding.pdf (150.4 K) QUEUED
    form1.xml (533 bytes) QUEUED
    Thanks
    Srini

  • Dynamic Form field name

    I have a shopping cart that creates a dynamic field for the
    quantity of each product in the cart. I need to be able to make
    sure the user does not submit a blank value. I can not use cfinput
    as per client instructions. The field is:
    <input name="Quant_#GetCart.ShowID#" type="Text"
    value="#GetCart.Quantity#" size="1" maxlength="2"
    title="Quantity"/>
    How would you go about validating Quant_#GetCart.ShowID#?
    Thanks in advance for the help/suggestions.

    LeftCorner,
    Thanks for the compliments, and for analyzing my code. It's
    cool to see you care. I agree that the find() should have been
    findNoCase(), and the inclusion of a trim() could be a good one,
    however, the evaluating is not better. In general, Evaluate() is
    becoming less used, and is being certainly phased out where it's
    not extremely necessary. There are a few arguments as to why,
    performance being one of them, readability being another. I stand
    by my code and I recommend you check out structure notation
    (structure[key] when you would normally write structure.key except
    you don't know what "key" really is) wherever possible.

  • How to dynamically add field name in where clause of select query in web dynpro?

    Hello,
    Can any body tell me how i can use select query with dynamic wheere condition.
    i have a requirement like there are multiple input fields  and i want to select data from two database
    and condition may vary .

    Hi
    In the where clause you need to write like
    WHERE NAME LIKE 'DE%'
    Regards
    Sudheer

  • Dynamic Target Directory name: DEV QUA and PRD

    Dear All,
    Scenario Idoc to File:
    I need to configure file directory's dynamically - when the object is moved to D, Q and Prd. for that am using plant and location to differenciate.
    InExample: D:\SX\Common\ <plant><location>
    TinAdvance
    Swarna.

    Swarna wrote:
    Dear All,
    >
    > Scenario Idoc to File:
    >
    > I need to configure file directory's dynamically - when the object is moved to D, Q and Prd. for that am using plant and location to differenciate.
    >
    > InExample: D:SXCommon <plant><location>
    >
    > TinAdvance
    > Swarna.
    I am assuming that the plan and location fields are part of the data structure and the path D:SXCommon will always remain the same in all the environments.
    In that case, you can write a generic UDF for this that will handle in Dev, QA and PRD
    use this blog to help you - Dynamic Configuration vs Variable Substitution - The Ultimate Battle for the File Name

  • Dynamic creating field names within Loop

    Hi,
    I've a record which comprises of a few key fields and then 52 qty fields, one for each week of the year. ( Not my design honest!!).
    Anyway with in a Cursor there are currently 52 "IF" statements clearing out values less than the current week number. I'd tried to replace this with the following. However I'm having trouble with the " 'c1_rec.qty'&#0124; &#0124;lv_count " bit.
    Has anyone got any ideas?
    lv_week:=22; ( added for clarity )
    lv_count:=1;
    WHILE lv_count < lv_week LOOP
    'c1_rec.qty'&#0124; &#0124;lv_count :=0;
    lv_count:=lv_count+1;
    END LOOP;
    John-Paul Thompson

    John-Paul;
    If I understand the question correctly, you have a table with 52 columns, one for each week of the year. You are trying to zero the quantity for each week prior to the current week. I'm going to take a sab at this. Bear in mind that I have no way to debug the code.
    DECLARE
    c NUMBER;
    n NUMBER;
    v_sql VARCHAR2(2000)
    lv_week NUMBER:=22; ( initialize week#)
    lv_count NUMBER:=1;
    BEGIN
    v_sql := 'UPDATE c1_rec SET '
    WHILE lv_count < lv_week LOOP
    v_sql := v_sql&#0124; &#0124;
    'qty'| |TO_CHAR(lv_count) &#0124; &#0124;' :=0';
    lv_count:=lv_count+1;
    IF lv_count < lv_week THEN
    v_sql := v_sql &#0124; &#0124; ', ';
    END IF;
    END LOOP;
    --sql := v_sql &#0124; &#0124; YOUR WHERE CLAUSE
    c:= dbms_sql.open_cursor;
    dbms_sql.parse(c, v_sql, dbms_sql.native)
    n:= dbms_sql.execute(c);
    dbms_sql.close_cursor(c);
    END;
    HTH
    Randall
    null

Maybe you are looking for

  • Deploy to single managed server checked and greyed out while performing upgrade to EPM 11.1.2.4

    Hi Gurus, We are trying to upgrade EPM from 11.1.2.2 to EPM 11.1.2.4 and have applied the maintenance release successfully. Issue: When we are trying to configure EPM 11.1.2.4 and are providing the same Shared Service database details, at the summary

  • How to change mouse pointers programmat​ically

    Normally when a VI is run, mouse pointer changes to 'Hand Pointer'.Is it possible to make it 'Arrow pointer' wherever no buttons are there and if buttons are there change mouse to 'Hand Pointer'. Thanks

  • License Validation Failed

    I get the following error when trying to use the SQL Server JDBC Driver with WL 6.0. The license we have a developer's license. We have that stored in license.bea in the bea home directory. I have that directory loaded up in the classpath as well. If

  • Adobe Edge 1.5

    Link to download Adobe Edge 1.5 in the apps environment of creative cloud seems to be broken........ now I can't go on with my work at the computer I'm working on at home......

  • Illustrator CC 2014 crashing on lunch

    When I try to lunch the new version of Illustrator it's crashing without even loading the interface. MacBookPro 15-inch 2.3Ghz with retina display w/ Mac OS X 10.9.3 (13D65)