Rename an XML tag using javascript

Dear adobe experts,
I have a requirement to rename XML tags, in the interface for an adobe form, using javascript.
the XML looks like this:
<ELEMENT>
     <DATA>
          <ROW_IID>0</ROW_IID>
          <PARENT>0</PARENT>
          <CHILD>0</CHILD>
     </DATA>
     <DATA>
          <ROW_IID>1</ROW_IID>
          <PARENT>0</PARENT>
          <CHILD>0</CHILD>
     </DATA>
</ELEMENT>
and the result should look something like this:
<ELEMENT>
     <CHAIR>
          <ROW_IID>0</ROW_IID>
          <PARENT>0</PARENT>
          <CHILD>0</CHILD>
     </CHAIR>
     <TABLE>
          <ROW_IID>0</ROW_IID>
          <PARENT>0</PARENT>
          <CHILD>0</CHILD>
     </TABLE>
</ELEMENT>
Is this possible and how can I do this? I was hoping that something like renameNode() (for instance) is also possible in the javascript set for adobe forms.
If it's not possible I'm going to have to create new nodes, put the data from the existing node in the new node and remove the original node. This will be a lot more work and just renaming is easier :-).
Kind regards,
Niels

Hi,
       Thanks a lot Jeff...
        I'm doing a huge program with lot of tasks. While doing that,my mind didn't strike to check if the tag is not already exist, then only to create new tag...  Thanks for all of the indesigner experts for their replies...
I used the following codes with ur idea.
                    var renamewith = textbox1.text;
                    try
                        alert(app.activeDocument.xmlTags.item(renamewith).name);
                        if(app.activeDocument.xmlTags.item(renamewith).name)
                           var testTag = app.activeDocument.xmlTags.item(renamewith);
                    catch(e)
                        var testTag = app.activeDocument.xmlTags.add({name: renamewith});
With Regards,
Vel.

Similar Messages

  • Overwriting the value of an html:hidden tag using javascript

    Hi!
    Can somebody help me with my problem?
    I need to overwrite the value of my html:hidden tag using javascript, but I dont know how?
    Any help?
    Thanks

    what are you talking about :x
    thats a webapplication question, wrong forum..
    But you are using STRUTS I would say...
    <html:hidden property="hiddenfield"/>This is the proper way of doing it.. but overrighting it
    I don't think you understand why we use that?
    It is only for forms.... we use that for hidden input ... It is common sence not to overrde that value.

  • Renaming XML tags via Javascript

    I currently have a script that finds certain paragraph styles and renames them. For example:
    var myDoc=app.activeDocument;
          var myStyle=myDoc.paragraphStyles.itemByName("SIDEBAR B HEAD");
          myStyle.name="SIDEBAR RATING HEAD"
    I'd like to do the same thing with some XML tag names, preferably as part of the same script. I'm sure it's fairly easy, but for some reason I can't find any info on how to call out XML tags!
    I've looked through the InDesign CS4 Scripting Tutorial and Adobe Introduction to Scripting, but at this point I feel like I'm wasting my time on a simple problem. Can anyone help out an amateur?
    Thanks in advance,
    Matt

    Or
    You can use this function for multiple rename tag
    var myDoc = app.activeDocument;
    RenamXMLTag("Old", "New");
    RenamXMLTag("Old", "New");
    function RenamXMLTag(Old, New)
         if(myDoc.xmlTags.itemByName(Old).isValid)
         myDoc.xmlTags.itemByName(Old).name = New;
    Shonky

  • Urgent help needed for XML Tags using XMLForest()

    Folks
    I need some urgent help regarding getting use defined tag in your
    XML output.
    For this I am using XMLElement and XMLForest which seems to work fine
    when used at the SQL prompt but when used in a procedure throws and error
    SQL> Select SYS_XMLAGG(XMLElement("SDI",
                                       XMLForest(sdi_num)))
         From sdi
         where sdi_num = 22261;- WORKS FINE
    But when used in a procedure,doesnt seem to work
    Declare
        queryCtx  DBMS_XMLQuery.ctxType;
        v_xml     VARCHAR2(32767);
        v_xmlClob CLOB;
        BEGIN
        v_xml:='Select SYS_XMLAGG(XMLElement("SDI",
                                             XMLFOREST(sdi_num)))
        From sdi
        where sdi_num = 22261';
        queryCtx :=DBMS_XMLQuery.newContext(v_xml);
        v_xmlClob :=DBMS_XMLQuery.getXML(queryCtx);
        display_xml(v_xmlClob);
    End;
    CREATE OR REPLACE PROCEDURE  display_xml(result IN OUT NOCOPY CLOB)
    AS
         xmlstr varchar2(32767);
         line varchar2(2000);
    BEGIN
         xmlstr:=dbms_lob.SUBSTR(result,32767);
         LOOP
         EXIT WHEN xmlstr is null;
         line :=substr(xmlstr,1,instr(xmlstr,chr(10))-1);
         dbms_output.put_line('.'||line);
         xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
         END LOOP;
    end;
    SQL> /
    .<?xml version = '1.0'?>
    .<ERROR>oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an
    XML tag name.</ERROR>
    PL/SQL procedure successfully completed.
    SQL>HELP is appreciated as to where I am going wrong?

    Hi,
    if you want to transform something to something else, you should declare, what is your source.
    I would prefer to use plain XSL-Transformations, because you have a lot more options to transform your source and you can even better determine, how your output should looks like.
    Kind regards,
    Hendrik

  • Remove Empty XML Tags using module parameters

    Hi All,
    In my lanscape I have two PI Systems.
    My scenario is an IDOC reaches 1st PI system gets converted into an EDIFACT and then goes to the 2nd PI and from there it gets routed to the respective AS2 Party.
    I am using SOAP to pass message between the PI systems and B2B Toolkit's AS2 Adapter for the communication with AS2 party.
    The issue is when the message is getting converted from IDOC to EDIFACT there are a few feilds with occurence 1..1 and due to these fields i get an empty XML tag at the output. These empty XML tags give me an error in the B2B Toolkit's AS2 Adapter Receiver Channel
    I cannot change the occurence in the structure of the EDIFACT nor can I use an XSLT mapping to remove empty tags before the message reaches the Communication Channel.
    I want to know if there are any module parameters which i can use either in SOAP Channel or the AS2 Channel to remove the XML Tags.

    Hi Muni,
    "1..1 means, you must send some values for that fields. try to find out why these are not getting any values."
    This empty tag is expected. Before using B2B Toolkit's AS2 Adapter we used to use Seeburger's AS2 Adpater and the message used to get executed successfully with these empty tags.The issue is coming only when we are using B2B Toolkit's AS2 Adapter.
    "if you want to stop sending(the fields which are not needed in target) you can you can disable the fields in the message mapping."
    I cannot disable the feild in the mapping as some other message may use this field.
    Thanks,
    Farhaan

  • Dynamic changes of option tags in a Select tag using JavaScript

    I got this problem during my project.
    I used Select tag in HTML code.
    I have to change options related to Select tag, based on events.
    How can we change options dynamically using JavaScript?
    Please post solution to this problem..

    You know Sun Java Studio Enterprise forum isn�t a right place for JavaScript & HTML questions.
    BTW here is you can find a lot of js stuff: docs, samples, tutorials, etc:
    http://www.w3schools.com/js/default.asp

  • Import xml/xsl using javascript

    I had problem in import a xml file with xsl using javascript. CS3 only take the elements in xml without any xsl information when I defined doc.xmlImportPreferences.transformFilename="c:\\sample.xsl"; What else do I need to define to allow CS3 know that my xsl file is sample.xsl.

    By the way, after I maunually import them, it can be handled by the program. I wonder there must be something missing when I try to import it viw Javascript at first time.

  • XML:selecting the value of a xml tag using plsql

    Hi,
    I have a table xx_table with one of the column xx_column which is of type XMLTYPE.I inserted the xml data into this column with xml data as below.
    <userComments xmlns:ns1="http://xmlns.oracle.com/XXXX_AccountDistribution"
    xmlns="http://xmlns.oracle.com/XXXXX_AccountDistribution">
    <task:userComment
    xmlns:task="http://xmlns.oracle.com/bpel/workflow/task">
    <task:comment>*********** Rejecting invoice **********</task:comment>
    <task:updatedBy>
    <task:id>r</task:id>
    <task:displayName></task:displayName>
    <task:systemVersionFlag></task:systemVersionFlag>
    </task:updatedBy>
    <task:updatedDate>2010-05-19T14:09:15-07:00</task:updatedDate>
    <task:displayNameLanguage></task:displayNameLanguage>
    <task:action></task:action>
    <task:systemVersionFlag></task:systemVersionFlag>
    </task:userComment>
    </userComments>
    My question ,how do i select the value of the tag "comment" from the above xml data using plsql? Can we write a query to select the value of the tag "comment" to fetch "*********** Rejecting invoice **********" as value.
    Regards,
    Sandeep

    If you have rights to modify tabular model then, you can create a measure in your Tabular model which returns previous week and then use this measure in Pivot Table.
    Thanks,
    Sagar K 
    (Blog: http://datamazik.blogspot.in/)

  • How to create nested xml tags using java parser?

    Hi,
    I need to create a xml file containing following tags using java program-
    <A attr1="abc">
    <B attr2="xyz">
    <C attr3="pqr"> </C>
    </B>
    </A>
    Can anyone please let me know which parser should I use to create the above mentioned xml file?
    If possible, please post a code snippet for the same.
    Thanks in advance..

    Well, you could start by doing it all the 'old fashioned' way; create a String object containing that text and then write it away to a file. Or you could take the time to look at the javadoc for all of the xml support that the Java language itself supplies - XMLReader/Writer for a start. After that put together some code that you think would do the job and ask for help on any specific problems you encounter.

  • Counting xml elements using javascript

    How can I count the number of certain xml elements inside the xml file that import.
    Example xml:
    <list>
         <product>
              <name>Product_01</name>
              <detail>info here</detail>
         </product>
         <product>
              <name>Product_02</name>
              <detail>info here</detail>
         </product>
         <product>
              <name>Product_03</name>
              <detail>info here</detail>
         </product>
    </list>
    I would like to count the number of product -elements in this example xml.
    I'm using javascript for scripting.
    Thanks.

    #target indesign
    #include "/Applications/Adobe InDesign CS3/Scripts/Xml Rules/glue code.jsx"
    var myDocument = app.activeDocument;
    var myCounter = 0;
    var myRuleSet = new Array (new ProcessProduct);
    with(myDocument){
        var elements = xmlElements;
        __processRuleSet(elements.item(0), myRuleSet);
    alert("Found " + myCounter + " product elements");
    function ProcessProduct(){
        this.name = "ProcessProduct";
        this.xpath = "//product";   
        this.apply = function(myElement, myRuleProcessor){
            with(myElement){
                myCounter++;
        return true;

  • Rename particular XML Tag

    Hi Indesign Experts,
              I'm confused a lot in the below issue. I'm have a indesign document. In the xml structure, If i select a element, and trying to rename the selected item's markupTag.name, it's changing all the elements with the selected elements name....
    I use the below code to run after selecting an xml Element.
    app.selection[0].markupTag.name="test";
    But the output look like the below.
    But I want onlu to rename the selected xmlelement.
    Any idea to perform this?
    Thanks and Regards,
    Vel.

    Hi,
           Thanks a lot Jeff...
            I'm doing a huge program with lot of tasks. While doing that,my mind didn't strike to check if the tag is not already exist, then only to create new tag...  Thanks for all of the indesigner experts for their replies...
    I used the following codes with ur idea.
                        var renamewith = textbox1.text;
                        try
                            alert(app.activeDocument.xmlTags.item(renamewith).name);
                            if(app.activeDocument.xmlTags.item(renamewith).name)
                               var testTag = app.activeDocument.xmlTags.item(renamewith);
                        catch(e)
                            var testTag = app.activeDocument.xmlTags.add({name: renamewith});
    With Regards,
    Vel.

  • Problems in creating xml tags using java

    i had analysed the xmlnode builder class but i am unable to learn what is the functions of that class.
    so please send me a sample coding to create the following output.
    i need this kind of output.
    <?xml version="1.0"?>
    <tree>
    <node id="acc" text="Accounts" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="1" text="Liabilites" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="5" text="Capital" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="L5" text="Gods A/c" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    <node id="10" text="Current Liablities" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="11" text="Cash On Hand" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="L11" text="Cash" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    <node id="12" text="Bank Balance" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="L12" text="ICICI" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    </contents>
    </node>
    <node id="2" text="Asset" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="6" text="Fixed Asset" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    <node id="3" text="Expenses" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="15" text="Direct Expenses" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2">
    <contents>
    <node id="8" text="Purchase" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    <node id="16" text="InDirect Expenses" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2">
    <contaents>
    <node id="L16" text="Staff Welfare" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contaents>
    </node>
    </contents>
    </node>
    <node id="4" text="Income" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="13" text="Direct Income" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2">
    <contents>
    <node id="7" text="Sales" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    <node id="14" text="InDirect Income" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con2"/>
    </contents>
    </node>
    </contents>
    </node>
    <node id="inv" text="Inventory" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="1" text="Raw Material" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1">
    <contents>
    <node id="I1" text="Pigments" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    <node id="2" text="Intermediate" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="3" text="Work In Process" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="4" text="Finised Goods" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    <node id="5" text="Packing Materials" cImage="tree/images/book.gif" oImage="tree/images/bookopen.gif" contextid="con1"/>
    </contents>
    </node>
    </tree>

    Unless you are using some special tag library or something, SQL is not, as far as I've ever seen, going to handle while loops within the statements. You want to create the table, then you have to create the CREATE statement string
    String c = "CREATE TABLE [dbo].[tblNewTable] (";
    for(int x = 0; x < vFieldFruitVector.size(); x++) {
       c += vFieldFruitVector.get(x) + " char 50 COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL";
    c += ")";
    int res = stmt.executeUpdate(c);

  • How to rename a XML file using the file/FTP adapter

    Dear All,
    I am trying to rename a file using VARIABLE NAME SUBSTITUTION.
    My structure:
    <ns1:MSg xmlns:ns1="http://www.mycomp.inf.br/msr">
      <ns1:MSgVal type="A" Id="188549">
        <ns1:cab>
          <ns1:PO>4500000000</ns1:cPO>
          <ns1:BI>90000000011</ns1:cBI>
        </ns1:cab>
      </ns1:MSgVal>
    </ns1:MSg>
    How do I do to get the value 188549 from the field Id that is into the tag MSgVal?
    I created a variable var1 and my reference is:
    var1 --> payload:ns1:MSg,1,ns1:MSgVal,1,Id@,1
    I am getting the error:
    Could not process due to error: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variable was not found in the message payload: var1
    Regards,
    Fernando

    Hi,
    Like pinted by Michal, use Adapter Specific Identifers.
    In your mapping set the file name using the code in this link and then in your Receivr File Adapter select the Adapter Specific Identifiers --> FileName .
    http://help.sap.com/saphelp_nw04/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
    Regards
    Bhavesh

  • Searching for XML tags using Oracle Text

    I am using full text search to find documents based on a search text. It works fine for pdf, word documents, etc. However for XML documents, searching for a particular tag name does not find anything. Searching for text within tags works fine. Any thoughts?
    Edited by: miyer on Feb 21, 2011 6:25 PM

    Hi
    Try adding the following variable to ucm config.cfg and then see if a new xml checkin returns the result for FT search :
    TextIndexerFilterFormats=xml
    Save the file , restart UCM and then test .
    If the new checkin gets the results as expected then execute Collection Rebuild cycle to have the existing contents as well FT indexed to be searchable (for XML).
    Thanks
    Srinath

  • How to comment the xml tags using java

    Iam using a xml file i want to comment some of the tags in that file

    And your quesion is? Did you parse it into a Document and do you want to write a changed version into another file?

Maybe you are looking for

  • Creative Cloud window opens, but nothing is displayed.

    I have tried uninstalling, cleaning, and reinstalling to no avail.  The window allows me to select 3 options from the cog in the upper right hand corner of the window: help, pin, or quit.  Any ideas of what i can do to fix this?

  • Web pages don't render properly no matter which Web browser I'm using

    I've run across a very curious issue - Web pages do not render correctly in either Internet Explorer (version 8, 9, 10, 11 - I've tried them all) or Firefox (latest version). If I visit a Web page that contains a commenting system (Disqus, Facebook,

  • Now i can't make a movie

    Hey, i managed to sort out the screen but it won't let me use videos or make a movie/trailer

  • Link to an external website based on form item

    Hello, How to create a link to an external site based on the value of a read only item in a form? I have a read only form (not a report because of layout issues) which presents address information. One of the items contains a site-address. Is it poss

  • EHPI not able to start and stop services shadowsystem

    All, I am working on an installation of EHP4 but am running in the following issue: When I get to the phase SHDINST_OS the EHPI is not able to stop and start the service for the shadowsystem. The ehpi log gives: Phase SHDINST_OS: SAPehpi> Starting su