Add ' ns1: "to a tag xml in a PLSQL

Hi friends,

in the xml below

I use DomNode approach to create the XML Core

and use the below query

SELECT XMLSERIALIZE (DOCUMENT xmlroot

((XMLELEMENT)

"ns1:DeriveCoverageRequest,"

XmlAttributes)

"urn: xyz:ccw:config:common: data ' AS 'xmlns '.

("urn: xyz:ccw:config:msa: data ' AS 'xmlns:ns1'),

l_xmltype)

version "1.0" encoding = "UTF - 8', AUTONOMOUS YES

)

AS CLOB)

in l_value

and the XML look like

<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"? >

< ns1:DeriveCoverageRequest xmlns = "urn: xyz:ccw:config:common: data" xmlns:ns1 = "urn: xyz:ccw:config:msa: data" >

< majorLine >-

< > 47285 lineId < / lineId >

xyz15454 < itemName > < / itemName >

< quantity > 5 < / quantity >

< minorLine >

< > 47293 lineId < / lineId >

15454-CC-FTA < itemName > < / itemName >

< quantity > 5 < / quantity >

xyz15454:15454 - < itemPath > < / itemPath >

< / minorLine >

< / majorLine >

< / ns1:DeriveCoverageRequest >

Double;

now, I have to add ns1: with the majorLine tag, it should be like

< ns1:majorLine >

< / ns1:majorLine >

Code for the creation of this majorLine is

l_major_line_node: =.

DBMS_XMLDOM.

appendChild)

l_root_node,

DBMS_XMLDOM.

makeNode (DBMS_XMLDOM.createElement (l_domdoc, 'majorLine')));

and I changed as

l_major_line_node: =.

DBMS_XMLDOM.

appendChild)

l_root_node,

DBMS_XMLDOM.

makeNode (DBMS_XMLDOM.createElement (l_domdoc, 'ns1:majorLine')));

but it did not work. could you please suggest an idea on that

Now you begin to see why this approach is wrong, not you?

Use only one method to build the entire XML code.

As I said, my preference goes to the SQL/XML functions, much easier to use than DOM when the source is relational data.

If you want to stick with DOM (bad idea) then, in addition to adding the prefix, you must also create the namespace attribute, otherwise the XML is not correct:

l_major_line_elem: = dbms_xmldom.createElement (l_domdoc, "ns1:majorLine");

dbms_xmldom.SetAttribute (l_major_line_elem, 'xmlns:ns1', ' urn: xyz:ccw:config:msa: data');

l_major_line_node: = dbms_xmldom.appendChild (l_root_node, dbms_xmldom.makeNode (l_major_line_elem));

Tags: Oracle Development

Similar Questions

  • Is it possible to add the tag XML columns in Table

    Hello world!

    I'm the new baby of the indesign forum. I need apply the tag XML to each column of the table (name probably test1, test2...)

    Please help me on this problem or even to correct my codes.

    -yajiviki

    My code.

    var docRef=app.activeDocument;
    var ColLen=app.activeDocument.stories.everyItem().tables.everyItem().columns.length;
    for(i=0; i<ColLen; i++){
        var mySel=app.activeDocument.stories.everyItem().tables.everyItem().columns[i];
        app.activeDocument.xmlElements[0].xmlElements.add({markupTag:"Test"+(i+1), xmlContent:mySel});
    }
    

    Hello

    You can easily mark the table initially with the automatic tag command.

    myTable.autoTag();
    

    Once this is done, you can target the cells in columns and reset the tag applied:

    var xes = myTable.columns[0].cells.everyItem().associatedXMLElement;
    var n = xes.length;
    while ( n-- ) xes[n].markupTag = "foo"
    

    HTH

    Loïc

    www.ozalto.com

  • reception of exception when I add <>servlet-descriptor in weblogic.xml

    When I add a session in weblogic.xml descriptor tag I get the following exception when I try to deploy it.

    My weblogic.xml file:

    <? XML version = "1.0" encoding = "UTF - 8"? >
    < weblogic-web-app xmlns = "http://www.bea.com/ns/weblogic/90."
    xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" >
    < security-role-assignment >
    Admin > role name < < / role name >
    < externally defined / >
    < / security role assignment >
    <>context-root / appA < / context root >

    * < descriptor of a session - > *.
    * < session-param > *.
    * < param-name > TimeoutSecs < / param-name > *.
    * < param-value > 3600 < / param-value > *.
    * < / session-param > *.
    * < / session descriptor > *.

    < / weblogic-web-app >

    Exceptions that occur:

    Cannot access the selected application.
    -Icon of Exception error message in the progress of AppMerge flow
    -Icon of Exception error message in the progress of AppMerge flow
    Message - problem error VALIDATION PROBLEMS FOUND icon: cvc-complex - type. 2.4: expected elements ' timeout-dry @http://xmlns.oracle.com/weblogic/weblogic-web-app invalidation-interval-dry @http://xmlns.oracle.com/weblogic/weblogic-web-app @http://xmlns.oracle.com/weblogic/weblogic-web-app debug-enabled-length of id @http://xmlns.oracle.com/weblogic/weblogic-web-app @http://xmlns.oracle.com/weblogic/weblogic-web-app tracking-enabled size cache @http://xmlns.oracle.com/weblogic/weblogic-web-app max-in-memory-sessions @http://xmlns.oracle.com/weblogic/weblogic-web-app @http://xmlns.oracle.com/weblogic/weblogic-web-app cookies @http://xmlns.oracle.com/weblogic/weblogic-web-app cookie-path the @http://xmlns.oracle.com/weblogic/ cookie @http://xmlns.oracle.com/weblogic/weblogic-web-app-domaine cookie-name WebLogic-web-app cookie-comment @http://xmlns.oracle.com/weblogic/weblogic-web-app cookie secure @http://xmlns.oracle.com/weblogic/weblogic-web-app cookie-max-age-dry @http://xmlns.oracle.com/weblogic/weblogic-web-app @http://xmlns.oracle.com/weblogic/weblogic-web-app cookie-http-only persistent-store-type @http://xmlns.oracle.com/weblogic/weblogic-web-app persistent-store-cookie-name @http://xmlns.oracle.com/weblogic/weblogic-web-app persistent-store-dir @http://xmlns.oracle.com/weblogic/weblogic-web-app persistent-store-pool @http://xmlns.oracle.com/weblogic/weblogic-web-app persistent data-source-jndi-name-@http://xmlns.oracle.com/weblogic/weblogic-web-app persistent session flush interval @http://xmlns.oracle.com/weblogic/weblogic-web-app persistent session flush threshold @http://xmlns.oracle.com/ WebLogic / WebLogic-web-app persistent-async-queue - timeout @http://xmlns.oracle.com/weblogic/weblogic-web-app persistent-store-table @http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app jdbc-column-name-max-inactive-interval@ jdbc-connection-timeout-dry @http://xmlns.oracle.com/weblogic/weblogic-web-app @http://xmlns.oracle.com/weblogic/weblogic-web-app url rewriting compatible http-proxy-cache-of-cookies @http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app encode-session-id-in-query-params@ surveillance-attribute-name @http://xmlns.oracle.com/weblogic/weblogic-web-app-sharing @http://xmlns.oracle.com/weblogic/weblogic-web-app' instead of ' session-param @http://xmlns.oracle.com/weblogic/weblogic-web-app» here in the @http://xmlns.oracle.com/weblogic/weblogic-web-app session descriptor element: < null >

    I think I understand:

    This error is due to the session-descriptor tag... I don't know why he is not accepted instead that it is completely correct.

    Any suggestions will be much appreciated.

    Published by: krathod11 on March 13, 2010 03:41

    Published by: krathod11 on March 13, 2010 03:42

    Hello

    Change the tag as follows


    3601
    2
    true


    -----------------------

    tag, we used in WLS8.1 weblogic.xml DTD... The schema that you use to weblogic.xml... is new

    .
    .
    .
    Thank you
    Jay SenSharma
    http://jaysensharma.WordPress.com (WebLogic wonders are here)

  • Is it a good idea to add predefined effects using presetEffects.xml?

    Hello

    I am currently working on a plugin using scriptUI.
    One thing I do is add a control null, which have many options for expressions.

    My basic problem is I want to sort them into groups for better ergonomics. The only way I found to do this, add some excerpts to presetEffects.xml. (please tell me if you know another way)

    Presents all works. So great. But now, I think, is it really a good idea? My main concern is: will they stay there? When the user is updating to a newer version of AE they are replaced?

    Y at - it other problems, that I should be aware?

    Thank you
    Jakob

    If you would not add new effects to null-controller, I think that the best way to organize things, is to create custom predefined ( you can use this script )

    store as a binary file inside your script, and then apply this preset.

  • Add the description of an xml file to the loaded image to full size

    Hi all

    I need a little help with the Gallery picture below please.

    I have a photo gallery that loads some thumbnail in via xml and AS3 support. When you click on the thumbnail, it loads the image full size in a charger.

    How can I add a description of the xml to the image full size.

    Thank you in advance for your time and effort to help me with this.

    I'm still learning a lot about AS3 and xml so your help is most appreciated people.

    It's my xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <menu>
    
        <items>
    
            <item>
    
                <url>thumb/1.jpg</url>
    
                <linkTo>fullsize\1.jpg</linkTo>
    
                <des>text I would like to appear in full image 1</des>
    
            </item>
    
            <item>
    
                <url>thumb/2.jpg</url>
    
                <linkTo>fullsize\2.jpg</linkTo>
    
                des>text I would like to appear in full image 2</des>
    
            </item>
    
            <item>
    
                <url>thumb/3.jpg</url>
    
                <linkTo>fullsize\3.jpg</linkTo>
    
                des>text I would like to appear in full image 3</des>
    
            </item>
    
            <item>
    
                <url>thumbs\4.jpg</url>
    
                <linkTo>fullsize\4.jpg</linkTo>
    
                des>text I would like to appear in full image 4</des>
    
            </item>
    
            <item>
    
                <url>thumbs\5.jpg</url>
    
                <linkTo>fullsize\5.jpg</linkTo>
    
                des>text I would like to appear in full image 5</des>
    
            </item>
    
        </items>
    
    </menu>
    

    It's my as3, I tried to take as much code that is not required in this example.

    var xmlPath:String = "pictures.xml";
    var xml:XML;
    
    var loader = new URLLoader();
    loader.load(new URLRequest(xmlPath));
    loader.addEventListener(Event.COMPLETE, xmlLoaded);
    
    function xmlLoaded(e:Event):void
    {
    
         
         if ((e.target as URLLoader) != null )
         {
              xml = new XML(loader.data);
              createMenu();
         }
    }
    
    var numberOfItems:uint = 0;
    var menuItems:Array = new Array();
    
    function createMenu():void
    {
              numberOfItems = xml.items.item.length();
    
         var count:uint = 0;
    
              for each (var item:XML in xml.items.item)
         {
    
              var imageLoader=new Loader();
              var menuItem:MenuItem = new MenuItem();
    
              menuItem.addChild(imageLoader);
              
              imageLoader.load(new URLRequest(item.url));
              
              menuItem.linkTo = item.linkTo;
              menuItem.mouseChildren = false;
              menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
              menuItems.push(menuItem);
              
              addChild(menuItem);
              
              count++;
         }
         ***();
    }
    
    function ***():void
    {
         //menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
         for (var i:uint = 0; i < menuItems.length; i++)
         {
              setChildIndex(menuItems[i], i);
         }
    }
    
    //**************************************loader for large images*************************************
    
    var loader_mc : Loader = new Loader();//loader_mc var for below itemClicked function
    
    //This function is called when a thumb is clicked
    function itemClicked(e:Event):void
    {
         var urlRequest:URLRequest = new URLRequest(e.target.linkTo);//Navigate to the URL that's assigned to the menuItem
         loader_mc.load(urlRequest);//adds the urlRequest to our loader_mc ;
    }
    
    //calling "contentLoaded" function if loading is over;
    loader_mc.contentLoaderInfo.addEventListener(Event.COMPLETE, contentLoaded);
    
    function contentLoaded(e:Event):void
    {
         addChild(loader_mc);//adds loader_mc to the stage     
    }
    

    No, you have some already loaded in your menuItem objects with the "menuItem.des = item.des;" line of code... which means this object contains the text of actual description right here.  If you just need to assign to the textfield object that you want to use to display the description.  In my example I named it 'someTextField', but you can name but you want.  Read my other answer about which you assign this value to the TextField.

  • How to read the xml value in plsql store proc

    I need to read the value at the bottom of the xml script in plsql procedure. I do not understand how to write. I'm new in xml, please help me solve this problem.


    <? XML version = "1.0" encoding = "UTF-8"? >
    < PrtyActDtlRequest >
    < AcctInfo >
    < > 84188 PartyID < / PartyID >
    < RelAcctID > 125148 < / RelAcctID >
    < RelAcctID > 251486 < / RelAcctID >
    < RelAcctID > 125147 < / RelAcctID >
    < RelAcctID > 125511 < / RelAcctID >
    < / AcctInfo >
    < / PrtyActDtlRequest >

    Here < AcctId > can be repeted n times (unbouinded), but < PartyID > is set once. This is the script that we will get out of the source system.

    Thanks in advance.

    Roy

    You needn't PL/SQL for it. Just use XMLTABLE:

    with t as)

    Select xmltype (')

    84188

    125148

    251486

    125147

    125511

    double x)

    Select PartyID,

    RelAcctID

    t,.

    XMLTable)

    ' / PrtyActDtlRequest/AcctInfo.

    go x

    columns

    PartyID path number "PartyID,

    Path RelAcctIDXml xmltype "RelAcctID."

    ),

    XMLTable)

    'RelAcctID '.

    by the way RelAcctIDXml

    columns

    RelAcctID path number ' / RelAcctID'

    )

    /

    PARTYID RELACCTID
    ---------- ----------
    84188 125148
    84188 251486
    84188 125147
    84188 125511

    Scott@pdborcl12 >

    SY.

  • R12 payment process Request Status Report add additional columns to the XML data.

    In 11i, we had modified the preliminary report of payment to include additional columns (distributions of invoice). R12, this report is obsolete and Oracle introduced a new report 'Payment process Request Status Report'. This query uses BI Publisher to generate the release of the final report. I can't edit the template for the output XML to the report has not
    contains data for distribution invoice account. We need to know how we can modify the XML data to include additional columns.

    For the disbursement of funds (payment instructions file) process, Oracle provides extensibility IBY_FD_EXTRACT_EXT_PUB package to build the custom XML element structure that can be added to the extracted XML payment generated by the Oracle payments. Do we have something similar to this report? Are there other options available?

    Thank you

    Hello

    The same "IBY_FD_EXTRACT_EXT_PUB" package also works for the payment request process status report. Please add the logic to get the distribution data in this package, and you'll see the new XML tags in this report also.

    I hope this helps.
    Serge

  • How to add URL links in the XML file?

    Hello

    I have a problem with adding the URL links to the power of lightning. I use the XML file to call images, then the corrsponding links. Images are called correctly but when I try to add a link I do not receive the links, but rather to get the anchor HTML text tags. I use escape XML characters to escape HTML tags, but the results are not what I need.

    I use the following code:

    < preview = "miniature large.jpg" thumb = "thumb.jpg" > "
    < title > <! [CDATA [Financial Services]] > < / title >
    < discription > <! [CDATA [& lt; a href = & quot; ]] http://www.google.ca "> Google < / a > " [[ ]] > < / discription >
    < / thumbnails >

    ---------------------------

    Output:

    Images are displayed correctly, but instead get the links, I get following message:

    " < a href =" http://www.Google.ca "> < /a > Google .

    I need to know what I'm doing wrong. I use the proper way to add links or not?

    Thanks for your time.

    Use tags html directly inside CDATA - after all, what CDATA is for.

  • How to extract the value of a tag XML using regular Expressions

    We get a response XML from a WEB SERVICE.

    I convert it to VARCHAR2.

    Now, I want to get the real answer that is inside the tag of the response.

    I tried this:

    DECLARE

    V_1 VARCHAR2 (30000): = ' < soap: Body > < ns:ProcessArgusFeedsResponse xmlns:ns = "urn: PegaRULES:SOAP:ArgusToPegaFeeds:Services" > ' |

    '< response > good < / answer >< / ns:ProcessArgusFeedsResponse > < / soap: Body > ';

    v_response VARCHAR2 (100);

    BEGIN

    DBMS_OUTPUT. PUT_LINE (V_1);

    v_response: = REGEXP_SUBSTR (v_1, ' / < >(.+?) < \/Response > answer /');

    dbms_output.put_line (v_response);

    END;

    It does not work.

    Any help would be greatly appreicated.

    Hello

    user12240205 wrote:

    We get a response XML from a WEB SERVICE.

    I convert it to VARCHAR2.

    Why?  XML has its own native ways of analysis; Why not use them?

    If you use regular expressions, then REGEXP_REPLACE, as shown above, is a good option in Oracle 10, but starting in Oracle 11.1, you can use REGEXP_SUBSTR like this:

    REGEXP_SUBSTR (v_1

    , '(.+?)'

    1

    1

    NULL

    1

    )

    The 6th argument is like a backreference; "He tells REGEXP_SUBSTR did not return to the entire organization, but only the part inside the 1st left '(' et correspondant à sa droite).

    The '?' to make it non-greedy is necessary only if v_1 can contain more than one response.

    Now, I want to get the real answer that is inside the tag of the response.

    I tried this:

    DECLARE

    V_1 VARCHAR2 (30000): = "" |

    'Good';

    v_response VARCHAR2 (100);

    BEGIN

    DBMS_OUTPUT. PUT_LINE (V_1);

    v_response: = REGEXP_SUBSTR (v_1, ' /(. +?)) <\ esponse="">/');

    dbms_output.put_line (v_response);

    END;

    It does not work.

    That's because it's looking for a slash ("/") before the '' tag and another after the ' tag.

    The backslash ("\") is not necessary here, but it is not nothing wrong.

  • Add image beside the import XML content

    Dear users of InDesign,

    Importing text in an InDesign template (essentially in a story).

    When I import this XML file do some tweaking with XML-rules, like adding a title.

    function AddHeading() {}

    myIdName = "AddHeading";

    This.XPath = "//phoneno [1];

    This.Apply = function (myElement, myRuleProcessor) {}

    {with (MyElement)}

    var myPhoneNo = myElement.xmlContent;

    myElement.xmlContent.insertionPoints [0] .silence = String ("phone numbers \r'");

    myPhoneNomentioning [0] .appliedParagraphStyle = app.activeDocument.paragraphStyles.item ("HeadingPhoneNo");

    }

    Returns true;

    }

    }

    What I need to do is add an Image (a phone icon) next to the additional title ("phone numbers ').

    Because everything is floating in a story, I can't have the geometric limits for this paragraph.

    Any ideas how to achieve a placement of an image in this context?

    Thank you!

    Thanks to Peter, here is the approach solve my problem:

    (adopted from pkahrel great help in this thread: Re: image of place as anchor object by finding the text...)

    function AddHeading() {}

    myIdName = "AddHeading";

    This.XPath = "//phoneno [1];

    This.Apply = function (myElement, myRuleProcessor) {}

    {with (MyElement)}

    var myPhoneNo = myElement.xmlContent;

    myElement.xmlContent.insertionPoints [0] .silence = String ("phone numbers \r'");

    myPhoneNo.words [0] .appliedParagraphStyle = app.activeDocument.paragraphStyles.item("HeadingPhoneNo");

    var anchor = myElement.storyOffset.textFrames.add ();

    var f = new File('/Users/PATHTOIMAGE/image.png');

    var f = [0,0, "10mm", "10mm"];

    var myObjectStyle = app.activeDocument.objectStyles.item ("HeadingPhoneNo");

    anchor.appliedObjectStyle = myObjectStyle;

    Anchor.contents = myElement.contents;

    anchor.geometricBounds = GB;

    Anchor.place (f);

    Anchor.fit (FitOptions.CONTENT_TO_FRAME);

    }

    Returns true;

    }

    }

  • How to add lines to the PresetEffects.xml from a script

    Hi, I would like to add a few lines in the PresetEffects.xml to another text file or an another JavaScript add lines like this how can I do? :

    < name of the group = "$$$ / AE/Preset/AnimalHead14 / = mouth" >

    < name of the cursor = "' $$$ / AE/Preset/AnimalHead14/MouthOffsetX = mouth X shift" default = '0' valid_min = '-30,000"valid_max ="30000"slider_min = slider_max"-500"= '500' precision ="1"DISPLAY_PERCENT ="true"/ >"

    < name of the cursor = "' $$$ / AE/Preset/AnimalHead14/MouthOffsetY = mouth Offset Y" default = "0" valid_min = "-30,000" valid_max = "30000" slider_min = slider_max "-500" = '500' precision = "1" DISPLAY_PERCENT = "true" / > "

    < name of the cursor = "' $$$ / AE/Preset/AnimalHead14/MouthScaleWidth = scale Overture" default = "100" valid_min = "-30,000" valid_max = "30000" slider_min = slider_max '-500' = '500' precision = "1" DISPLAY_PERCENT = "true" / > "

    < name of the cursor = "' $$$ / AE/Preset/AnimalHead14/MouthScaleHeight = scale of mouth height" default = "100" valid_min = "-30,000" valid_max = "30000" slider_min = "-500" slider_max = "500" precision = "1" DISPLAY_PERCENT = "true" / > "

    < / Group >

    < / effect >

    {function onClick.btn

    Add the lines of my text file in the PresetEffects.xml

    I did once, like this:

    var scriptEffect = {};
    scriptEffect.xml =
    
        
            
            
        
        
            
            
            
        
    ;
    scriptEffect.matchName = [email protected]();
    
    function installScriptEffect(){
    
        var ret;
        var file = new File(Folder.appPackage.absoluteURI + "/PresetEffects.xml");
        var str, idx, header, xml;
        var xmlSettings = XML.settings();
    
        XML.setSettings(XML.defaultSettings());
    
        try{
            if (!file.exists) throw "ERR_FILE_NOT_FOUND";
    
            file.open("r");
            str = file.read();
            file.close();
    
            idx = str.indexOf("");
            if (idx<0) throw "???";
    
            header = str.substring(0, idx-1);
            xml = new XML(str.substring(idx, str.length));
    
            if (!xml.contains(scriptEffect.xml)){
                xml.appendChild(scriptEffect.xml);
                if (!file.copy(new File(file.absoluteURI+".bak"))) throw "ERR_CANNOT_WRITE";
                file.open("w");
                if (!file.write(header + xml.toXMLString())) {file.close(); throw "ERR_WRITE_FAILED";};
                file.close();
                alert("Preset installed succesfully. Please restart After Effects");
                }
            else{
                alert("Preset already installed. You need to restart After Effects to make it effective.");
                };
            ret = true;
            }
        catch(e){
            file.close();
            alert(e);
            ret = false;
            };
    
        XML.setSettings(xmlSettings);
    
        return ret;
        };
    

    Then, when you want to add the effect, check with myLayer.effect.canAddProperty (scriptEffect.matchName).

    If true, nothing to do, otherwise use the installScriptEffect function. Normally, it works (haven't tried for a long time).

    Xavier

  • How to get the value of the label tag XML.

    To get the label for the page element I use under the piece of code. But the same code does not work for the inline xml tag.

    PMString TestUtility::GetScriptLabel (UIDRef pageItemRef, PMString key)

    {

    PMString labelValue;

    labelValue.SetTranslatable (false);

    InterfacePtr < IScript > iscript (pageItemRef, IScript::kDefaultIID);

    If (iscript)

    {

    If (key is 'default')

    {

    labelValue = iscript-> GetTag();

    }

    on the other

    {

    labelValue = iscript-> then (key);

    }

    }

    Return labelValue;

    }

    Please suggest something.

    The following function should do the job:

    PMString GetXMLTagLabel(IDocument* doc, WideString& tagName) {
        PMString label("");
    
        if(!doc)
          return label;
    
        InterfacePtr tagList(doc->GetDocWorkSpace(), UseDefaultIID());
        if(tagList)
        {
            UID tagUID  = tagList->GetTag(tagName);
            UIDRef tagRef = UIDRef(::GetDataBase(doc), tagUID); 
    
            InterfacePtr script(tagRef, UseDefaultIID());
            if(script) {
                 label.Append(script->GetTag());
            }
       }
       return label;
    }
    
  • Add the node to the xml file

    Hello

    I'm trying to scan a file xml in the following way:

    // read the content
        var xml_file = File(xml_file_path);
        xml_file.open('r');
        var content = xml_file.read();
        xml_file.close();
    
        // add the node
        var root = new XML(content);
        var unit_test_resolution = <unit-test>{resolution}</unit-test>;
        root.appendChild(unit_test_resolution);
    
        // replace the file
        var my_file = new File(xml_file_path);
        var edit_content = root.toXMLString();
        my_file.open('w');
        my_file.writeln('<?xml version="1.0" encoding="UTF-8"?>');
        my_file.writeln(edit_content);
    

    I'm not sure it's a good solution can someone help me? For example, my file already has the ' <? XML version = "1.0" encoding = "UTF-8"? > ' header. But if I read it this way I must put it each time egain...

    Thank you in advance for your help.

    Best regards.
    Bastien

    It's xtools/xlib/stdlib.js. I used it to manage my file xml reading and writing for several years.

    Stdlib.readXMLFile = function(fptr) {
      var rc;
      var file = Stdlib.convertFptr(fptr);
      if (!file.exists) {
        Error.runtimeError(48); // File/Folder does not exist
      }
      file.encoding = "UTF8";
      file.lineFeed = "unix";
      rc = file.open("r", "TEXT", "????");
      if (!rc && Stdlib.IOEXCEPTIONS_ENABLED) {
        Error.runtimeError(Stdlib.IO_ERROR_CODE, Stdlib.fileError(file));
      }
      var str = file.read();
      rc = file.close();
      if (!rc && Stdlib.IOEXCEPTIONS_ENABLED) {
        Error.runtimeError(Stdlib.IO_ERROR_CODE, Stdlib.fileError(file));
      }
      return new XML(str);
    };
    Stdlib.writeXMLFile = function(fptr, xml) {
      var rc;
      if (!(xml instanceof XML)) {
        Error.runtimeError(19, "xml"); // "Bad XML parameter";
      }
      var file = Stdlib.convertFptr(fptr);
      file.encoding = "UTF8";
      rc = file.open("w", "TEXT", "????");
      if (!rc && Stdlib.IOEXCEPTIONS_ENABLED) {
        Error.runtimeError(Stdlib.IO_ERROR_CODE, Stdlib.fileError(file));
      }
      // unicode signature, this is UTF16 but will convert to UTF8 "EF BB BF"
      // optional
      //file.write("\uFEFF");
      file.lineFeed = "unix";
      file.writeln('');
      rc = file.write(xml.toXMLString());
      if (!rc && Stdlib.IOEXCEPTIONS_ENABLED) {
        Error.runtimeError(Stdlib.IO_ERROR_CODE, Stdlib.fileError(file));
      }
      rc = file.close();
      if (!rc && Stdlib.IOEXCEPTIONS_ENABLED) {
        Error.runtimeError(Stdlib.IO_ERROR_CODE, Stdlib.fileError(file));
      }
      return file;
    };
    

    A lot of paranoia coding in there, but after having done PSJS coding for a decade or so paranoia is a more secure state of mind.

    X

  • Add the ID of the XML element to all elements as an attribute

    Hello

    The title says I hope that what I like to do. I have quite some documents that are marked, but add an id to all the elements of better handling external XML in Indesign. I've been looking around a bit but seems not forever be disturbed by many people...

    So, how can I iterate through all my items in XML and adds the ID of the element as an attribute?

    Thank you

    Koen

    Hi Koen,

    Please try the JS code below. This code its InDesign CS5.5 work.

    var myDoc = app.activeDocument;
    try{
        var rootElement = myDoc.xmlElements.item(0);
        var linkElementList = rootElement.evaluateXPathExpression("//para");
        for(i=linkElementList.length-1; i>=0; i--){
            var myAttribute = linkElementList[i];
            myAttribute.xmlAttributes.add("idname", "idvalue");
            }
        }catch(e){}
    

    THX,

    csm_phil

  • Find, edit, and remove the tag XML (Adobe InDesign Server CS5)

    Hi all

    I work with Indesign CS5 server and JavaScript, although having some difficulties to come with a solution to a problem...

    I have to build a script JS (called through SOAP) that will allow me to search for an XML tag in an InDesign file.

    After you find the XML tag, if the variable 'action' is set to remove, it should remove the tag and its content.

    If the action is set to edit, he should change the content of the tag to the user-defined content.

    The main warning is that the XML tag is variable, as is the XML of the InDesign file structure.

    Here's what I have in mind, in pseudocode:

    function findXMLTag (tag, action) {}

    app.searchForTag (tag);

    If {(tagIsFound)

    If (action == 'delete') {}

    tag. Delete;

    } Else if (action == 'edit') {}

    tag.contents = "update content";

    }

    }

    }

    Any help would be greatly appreciated!

    Thank you

    Ben Kay

    'searchForTag' can be implemented as a recursive function.

    Recursion is defined as follows: I thought: "I'll just get this forum for"recursion"." The first post I found was one of my own, which suggests that the poster should search the forum for "recursion".

    Here is an example: find the XML element []

    And another: remove the xml using JS [CS3] element (read carefully, as the OP is stuck on how to remove an item and continue successfully)

    And the other using XML rules - which I am quite familiar with, but may work for you: changing values in XML tags

Maybe you are looking for

  • Slow connection wired Internet in Bootcamp?

    So I've implemented (undeer 10.11.5) a bootcamp partition on my Mac Pro 5.1 on the first disc (Bay 1). Installed win7/64. Got all of the updates from m$ and installed components of bootcamp. Everything works well, even went and got a benchmarking app

  • delete more then an email?

    I can only remove 1 post at the time when I connect to my account gmail with firefox browser. Is this a common bug?Open Spanish version of ZTE. Ben

  • Satellite Pro M40: computer stops when you press the SHIFT key

    Sometimes when I press the shift key it wonder if I want to shut down the computer. It also changes the internet Explorer mode in full screen. When it arrives it will be continually for centuries and then suddenly stop. Then start again. It seems not

  • DC 5800 no sound. XP Pro

    I have now two dc 5800. More recent came with 4 GB of RAM, videocard ATI Radeon 4770, 2.93 GHz double heart and no operating system. I installed my XP Pro, including all updates and SP3. Also driver audio HP site. No sound. Took a look in the BIOS an

  • Server T310 disco RAID 0 da auswechseln [CF]

    Buongiorno, service tag 5P3995J Server T310 ha UN guasto disco da auswechseln (1 to). Chiedo come posso hope he pezzo che sia compatibile con he sistema anche a di firmware level. Grazie Fabrizio Di Meo