DOMException on setting node value

Hi,
I get the following error
oracle.xml.parser.XMLDOMException: Node cannot be modified
while trying to set the value of a newly created node as below:
String eName="Mynode";
XMLNode aNode = new XMLNode(eName, Node.ELEMENT_NODE);
aNode.setNodeValue(eValue);
How do I create a node whose value I can set later on?
Thanks,
Bhaskar
null

If you check the DOM spec referring to the table discussing the
node type, you will find that if you are creating an element
node, its nodeValue is to be null and hence cannot be set.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Bhaskar Deka (guest) wrote:
: Hi,
: I get the following error
: oracle.xml.parser.XMLDOMException: Node cannot be modified
: while trying to set the value of a newly created node as below:
: String eName="Mynode";
: XMLNode aNode = new XMLNode(eName, Node.ELEMENT_NODE);
: aNode.setNodeValue(eValue);
: How do I create a node whose value I can set later on?
: Thanks,
: Bhaskar
null

Similar Messages

  • Setting Node value in a DOMtree

    Hello Techies,
    I am trying to create a DOM Tree. I had create Node's for the DOM Tree. I want to know how to set the Values to these Nodes.
    Element root = null;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.newDocument();
    root = document.createElement(Root_Element);
    document.appendChild(root);
    Element applicationElement =document.createElement(Application_Element);
                applicationElement.setNodeValue("krish");
      root.appendChild(applicationElement);Now when I try to get the This Node Value , I am getting null Pointer Exception.
    Here is my code of retrieving the node value
    NodeList applicationNodeList = null;
    applicationNodeList =finalElement.getElementsByTagName("application");
    System.out.println("applicationNodeList size"+applicationNodeList.getLength());
          for(int i = 0; i<= applicationNodeList.getLength();i++)
               System.out.println("eachApplicaiton in the DOM"+applicationNodeList.item(i).getNodeValue());
               }I am getting NodeList size is 1 , but I the node Value I am getting as Null.
    What I am doing for setting the Node Value is correct(or) am I missing some thing.
    Can u guys help me out to fix this problem.
    regards,
    Krish.

    Thanx 4 u r reply.
    I had found where exactly the problem is .The element Node will take only null values.
    I have to create a DOM Tree in the following format.
        <Application>
            <application_id>   1 </application_id>
            <application_name>krish    </application_name>
            < description>   This is test </description>
      </Application>The values that I am placing in the following tags tage<application_id>,<application_name> and <description> are from database.
    My Code is
    Element root = null;
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.newDocument();
    root = document.createElement(Root_Element);
    document.appendChild(root);
    Element applicationElement =document.createElement(Application);
    root.appendChild(applicationElement);
    Element applicationIdElement =document.createElement(application_id);
    applicationIdElement.setNodeValue("1");
    appliationElement.appendChild(applicationElement);
    Now let us suppose that I had created Text Node
    TextNode t  =  applicationElement.createTextNode(application_id);
    applicationElement.appendChild(t);Now The value which I am getting from database I am not sure that it is always be a String , Some times , it may be
    int,bigInt,String,Clob.
    In this situation How can I create DOM Tree??
    To obtain the above xml structure, Whether I have to create text Node's under application?? Plz guide me.
    Looking forward 4 u r solutions
    Regards,
    Krish

  • Setting node value of self closed tags

    Hi all, I was just wondering if anyone knew the answer to this problem, I'm new to this level of java programming and I've been reading documentation till my eyes have started bleeding. When I use the setNodeValue() function on an element, it works fine UNLESS the node is self closed, in which case i cannot access it as it comes up as null. If anyone can give a sample code, or point me in the right direction I'd appreciate it

    by "it" i mean the node itself, and by "comes up as", i mean that the value of the node (and data type apparently) is null. Here is the code snippet that i currently have;
    NodeList nodeLst = doc.getElementsByTagName(repeatedNode);
    for (int s = 0; s < nodeLst.getLength(); s++) {
         Node fstNode = nodeLst.item(s);
         if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
              Element fstElmnt = (Element) fstNode;
              NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("status");
              Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
              Node test = (Node) fstNmElmntLst.item(0);
              if (fstNmElmnt != null){
                   NodeList fstNm = fstNmElmnt.getChildNodes();
                   if ( ((Node) fstNm.item(0)) != null ){
                        ((Node) fstNm.item(0)).setNodeValue("testing setvalue");
    }Notice the checks against null that I have in the code, those are to check against the self closed tages (eg <node />). I realize that there is nothing wrong with xmnl being formatted in this way, I just need to find a way to set values in those nodes. From reading the documentation on setNodeValue() ( [http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html#setNodeValue(java.lang.String)|http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Node.html#setNodeValue(java.lang.String)] ), the function cannot be used on a node that is of type null. What I'm trying to figure out is what to use instead yo be able to set the values of those "null" nodes.
    Edited by: Billy1234 on Jul 3, 2008 6:01 AM

  • Tree set node value

    Hello. I really need some from you. I'm working with a tree and I want to change the value of a node (I know the row of that node so I can find the path to it) . Can anyone help me?There is something like setValueAt(tree,row...) ??
    Please! I need urgent help.
    Thanks alot.

    setUserObject?

  • Not able to set the value in marketing context node for BP_HEAD

    Hi,
    I am trying to set the value in marketing node of BP_HEAD from bp_addr component. i am calling the set_property method but it is not changing the value, when i debugg the code, it actually changing the value in bol structure but it is not calling the get/set method of bp head.
    i am working on BP corporate person  creation i.e. in bp_head component and account details view. I added the marketing attributes in UI configuration and also the address attributes.
    this is what i coded in get method of country in standardaddress context node of BP_ADDR
    lv_entity ?= current.
        IF lv_entity IS BOUND.
          lv_parent = lv_entity->get_parent( ).
          IF lv_parent IS BOUND.
            lv_entity_mkt = lv_parent->get_related_entity( iv_relation_name = 'BuilMarketingRel' ).
            IF lv_entity_mkt IS BOUND.
              CALL METHOD lv_entity_mkt->set_property
                EXPORTING
                  iv_attr_name = 'ATTRIBUTE'
                  iv_value     = attribute1.
    Can anyone please guide me on how to set the value cross component and can we call the get/set method of that attribute which is not in same component?
    Regards,
    Kamesh Bathla

    Sorry, what I said was rubbish, because the LSMW and the session run in different external sessions.
    I have searched forum for these terms: "company BUK parameter BDC background"
    These threads Is it possible to set default company code in SM35? and Release BDC in SM35 in background, How to set defaul company code? seem promising, but I'm not sure they really solve.
    In case these threads don't help you, I think you can create your own Z transaction which sets the BUK parameter id and then does a LEAVE TO TRANSACTION 'ABAON'. Then create again the recording on the Z transaction.
    If you are using ECC6, then you may also enhance the standard to reset BUK parameter id at the very beginning of ABAON, in case it's run in batch input (sy-binpt = 'X'). Be careful as sometimes SAP does batch input on some transactions, so that could make the standard fail.
    Last thing, you can contact SAP support, though it might probably be considered as consulting.

  • How to set the value in the xml node.

    Hi
    I am having the application PDF which can be submitted by user using the button. while submitting 
    i am using below code to set the value in the xml node.
       xfa.data.assignnode("employee.id","123",0):
    So its generating the xml like below.
    <employee>.
    <id>123</id>.
    </name>
    </employee>
    Now i need to generate the xml like  below.
    <employee id= "123" >
      </Name>
    </employee>
    So how to set/create the id node like above?
    Advance Thanks.
    Regards,
    Dhiyane

    Hi Dhiyane,
    You will have to set the contains property if the id node to "metaData", that is;
    xfa.data.assignNode("employee.id","123",0);
    xfa.data.employee.id.contains = "metaData";
    Very clumsy if you have a number of them, in which case you might want to look at using E4X.
    Good luck
    Bruce

  • How to set default value to a node attribute programmatically?

    Hi Experts
             How to set a default value to a context node attribute programmatically? Any code snippet will be really helpfull. I am talking about the attribute inside a node in context.
    Note: This is for webdynpro for ABAP
    Thanks
    Gopal

    Hi Gopal,
    Assume you have the node called TEST and attribute called NAME then to set the value of NAME, you can use the following code say in WDDOINIT method or any other method.
    data:
        Node_Test                           type ref to If_Wd_Context_Node,
        Elem_Test                           type ref to If_Wd_Context_Element,
        Stru_Test                           type If_Componentcontroller=>Element_Test ,
        Item_NAME                           like Stru_Test-NAME.
    navigate from <CONTEXT> to <TEST> via lead selection
      Node_Test = wd_Context->get_Child_Node( Name = wd_This->wdctx_Test ).
    get element via lead selection
      Elem_Test = Node_Test->get_Element(  ).
    set single attribute
      Elem_Test->set_Attribute(
        exporting
          Name =  `NAME`
          Value = 'Value').
    Note: You can use Weddynpro code wizard to get this code. (Ctrl+F7)
    Regards,
    Srini.

  • Error in Invoke Node-Set Control Value

    I've a trouble with a VI: the error cluster warns ERR(7) when I try to pass the output of the "FLATTEN TO STRING" function to an Invoke Node-Set Control Value.
    In the file attachments there's the upmentioned VI. Thank you
    Attachments:
    Cambia_i_valori_di_default.vi ‏147 KB

    Error 7 is file not found. I would think that this error is generated by one of your Open VI References and not any of the Set Control Values. Check your paths and verify that they're correct. Also, you haven't included two subVIs or the VIs that you're trying to modify so it's impossible for anyone to try and recreate your problem. Save them into an LLB and attach that if you still have problems and want some help.

  • Is there a way to reference the property node value of a control in another VI?

    Let's say that I have a situation like the one shown in the attached image.
    I have an interlock system which is basically a bunch of booleans
    If for example the "RF Enable" button in the "interlock VI" is true, then I should be able to flick the ON switch in my other VI (in the back), but if the value is FALSE, then it shouldn't allow it.
    In other words, how do I check the value of a control across 2 separate VIs (running simultaneously)?
    Thanks!!
    Attachments:
    sample.jpg ‏295 KB

    Is one VI launched by the other, or are they launched independently? If it's the former then you just need to pass the control reference to the subVI via terminal node. If it's the latter there are a variety of ways to handle this:
    Use a global variable - somewhat "sloppy" as it requires a global variable, and can lead to race conditions. In the "Interlock" VI you just set the value of the global variable when you change the value of the Boolean. In the other you're just reading it.
    Action Engine - Ben wrote a Community Nugget a while back. Similar concept to a global variable.
    Queue - The "Interlock" VI simply pops an element onto the queue with the value. The other VI just monitors the queue for a new element. It just needs to have something like a shift register to keep track of the last state.
    Use the VI Server to access the controls of the "Interlock" VI. You can do this by accessing the "Interlock" VI's pane and get the control references. With the control reference you just need to get the value with a property node.
    ... (I'll let others chime in)

  • How do I set the value of a dynamic row text field

    I have a repeated row form which contains a button and multiple text fields.  There is a text field (Input Data Field) further up with some information I want to place in the table and multiple buttons that I want to read the value of and set to the table.  I apologize there are multiple questions I have and I am using pseudocode to describe it.
    Top form looks like
    InputField
    | ButtonX1 | ButtonY1 | DescriptionX1 (read only Text Field)
    | ButtonXn | ButtonY1 | DescriptionXn
    OutputRow looks like
    | ButtonOutput | OutputField1 | OutputField2 | OutputField3 |
    So I would like it to do
    ButtonX1.click
    OutputTable.OutputRow.addInstance(true)  //this works - everything else I have questions on
    OutputTable.OutputRow.OutputField1.rawValue = DescriptionX1.rawValue
    Question 1
    How do I address the location in each table to set a value
    Question 2
    How do I get the value of the description field in the same table and row as the button
    I would like to say something to the effect of  OutputTable.OutputRow[??].OutputField1.rawValue = this.parent.DescriptionX
    OutputTable.OutputRow.OutputField2 = InputField.rawValue
      Same question as above - how do I specify a dynamic row - is this the proper syntax for getting the value from the input field?
    OutputTable.OutputRow.OutputField3 = this.ButtonLabel
    Question 3
      How can I get the value of the button's label to set in the field
      There should be very many of these buttons and buttons will be added - I would prefer to set the value based on the button's label to make the value easier - not requiring changing the code
    Question 4 - unrelated to those above.
    Is it possible to build the first table
    | ButtonX | ButtonY | Description |
    from an XML File.  I have seen examples of how to build if it is just data, but can the XML be pushed into a form with code to do the above actions?

    Each object in a form must have a unique name. I doing so it is not neccessarily the name but the path or SomExpression associated with that object that must be unique. In your case you have a Table.Row.object configuration. The Row is the part that is repeating so to give each object a unique name an instance number is placed on the repeating part. So objects in the 1st row woudl be Table.Row[0].object...objects in the second row woudl be Table.Row[1].object etc .....You can see this by adding a debug instruction on the Enter event of the description field. Put the code app.alert(this.somExpression) and when you enter the field you will see what the somExpression is. Do this for a few rows and you will see the pattern (don't forget to remove the debug code from the enter event). Now you know what you have to use to address the fields. If no instance is given it is assumed to be 0 ..that is why only the 1st row is being affected.
    So now to answer your questions:
    Question1: The square bracket notation is an issue for javascript (this is the notation for an array) so we have to use a different means of addressing the field to include the instance number. So to address the Description in the 3rd row we woudl use:
    xfa.resolveNode("Table.Row[2].Description").rawValue = "This is my new description";
    Note that the instance number is 2 for the 3rd row because the instance numbers are 0 based.
    Question2. The resolveNode notation allows you to pass a string so you can also concatinate expressions to make the string. If you are writing code on a button in the same row you can get the instance that you are on by using the expression this.parent.index. The "this" portion refers to the current object (the button) and the parent.index gets you th eindex of the Buttons parent. If the button is embedded deeper in a hierarchy then you can continue to add parent indicators until you get back to the node that you want. So rewriting your expression from Q1 it woudl be:
    xfa.resolveNode("Table.Row[" + this.parent.index + "].Description").rawValue = "This is my new description";
    Question3: The buttons caption can be retrieved by using ButtonName.caption.value.text.value
    Question4: When you say build from an XML file. What are you expecting to come from the XML file? The caption that goes on the button? Typically the XML file carries data (not to say that it cannot carry other things). Just need a bit of clarification on this one first.
    Hope that helps
    Paul

  • Xml: how to get node value when pasing node name as a parameter

    Hi,
    I've got some xml:
    var xmlData:XML =
    <1stNode>
        <buttonID>first child node value</buttonID>
        <imageID>second child node value</imageID>
        <labelID>third child node value</labelID>
    </1stNode>
    Then I want to read specific node value based on a value passed to a function. .
    var buttonID = new Button;
    var imageID = new Image;
    var labelID = new Label;
    getNodeValue(buttonID); //the value here is set dynamically
    private function getNodeValue (nodeName:String):void {
    trace (xmlData.nodeName)                      //doesn't work
    var str:String = "xmlData." + nodeName;
    var xml:XMLList = str as XMLList             //doesn't work
    I'm don't know how to get the value when node name is dynamically changed.

    use:
    getNodeValue(buttonID); //the value here is set dynamically
    private function getNodeValue (nodeName:String):void {
    trace (xmlData[nodeName])                    

  • How to get the selected node value of a tree which is build on java code

    Hi Experts,
    How can i get the selected node value if I build the tree programatically.
    I am using the following code in selectionListener but it is throwing error.
    RichTreeTable treeTable = (RichTreeTable)getQaReasontreeTable();
    CollectionModel _tableModel =
    (CollectionModel)treeTable.getValue();
    RowKeySet _selectedRowData = treeTable.getSelectedRowKeys();
    Iterator rksIterator = _selectedRowData.iterator();
    String selectedQaCode ="";
    while (rksIterator.hasNext()) {
    List key = (List)rksIterator.next();
    JUCtrlHierBinding treeTableBinding =
    (JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
    JUCtrlHierNodeBinding nodeBinding =
    treeTableBinding.findNodeByKeyPath(key);
    String nodeStuctureDefname =
    nodeBinding.getHierTypeBinding().getStructureDefName();
    selectedQaCode = selectedQaCode + nodeBinding.getAttribute(0);
    where I am using following link to create a tree with java code.
    http://one-size-doesnt-fit-all.blogspot.com/2007/05/back-to-programming-programmatic-adf.html
    Please help me in resolving this issue.
    Regards
    Gayaz

    Hi,
    you should also move
    JUCtrlHierBinding treeTableBinding =
    (JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
    out of the while loop as this is not necessary to be repeated for each key in the set
    Frank

  • How to modify a node value in a DOM tree?

    I have following code; it parses a XML file from a file and builds a in-memory DOM tree, but when I tries to modify one of the node value, it keeps telling me: oracle.xml.parser.v2.XMLDOMException: Node cannot be modified. How do I do it?
    // ==================================
    DOMParser theParser = new DOMParser();
    theParser.setValidationMode(false);
    InputStream theInputStream = myApp.class.getResourceAsStream("/test.xml");
    theParser.parse(theInputStream);
    XMLDocument theXMLDoc = theParser.getDocument();
    NodeList theNodeList = theXMLDoc.selectNodes("/root/child");
    for (int i = 0; i < theNodeList.getLength(); i++)
    theNodeList.item(i).setNodeValue("test");
    null

    You're trying to set the node value of an element, which cannot have a node value.
    You need to set the node value of the text-node child of the element instead.
    Or remove the current text-node child and append a new text-node child with the new value.

  • Get Node Value in XSLT

    Hi all.
    Maybe a simple question but, I haven't done yet.
    In BPEL, when I need to get a node, I use getVariableData XPath function, for example:
    count(bpws:getVariableData('MtlSystemItemsBESB_OutputVariable','MtlSystemItemsBCollection','/ns7:MtlSystemItemsBCollection/ns7:MtlSystemItemsB')) to get the number of lines returned from the service call.
    Now, when I use XSLT transformation in ESB, I don't have a variable to extract the value from. So, how do I use XPath expressions that involve node-set return values?
    I tried something like count('/ns7:MtlSystemItemsBCollection/ns7:MtlSystemItemsB') but it does not seem to work.
    Thanks
    Denis

    Hi Denis,
    count('/ns7:MtlSystemItemsBCollection/ns7:MtlSystemItemsB') should work as expected. Have you double checked your XPath (namespace, elementnames, etc.)?

  • Any opinions on setting default values on Business Partner level?

    Hi All,
    I do not have a question, but would like to have a good discussion on how you should preferably be setting default values on a business partner and it's assignment blocks.
    In my opinion you have two main alternatives:
    1. The "old fashioned" way by using the get_<attribute_name> method and doing some checks for the perticular attribute in the context node.
    2. Using the Badi BADI_CRM_BP_UIU_DEFAULTS to fill fields with a default value. With some enhancements on the assignment blocks (making typed_context attribute public and, when not called yet, calling the badi) you can use the badi for all assignment blocks.
    Because I discovered via debugging that in the, by many forums suggested, badi code a programm error/exception is used so that the default values are only set during creation mode, I started doubting to use the badi. Because once I had set my data declarations to the right references and the exception did not occur anymore, suddenly it always fills the values even when there are already values filled. So additional checks are needed to assure that I am in creation mode.
    Although I like the use of the badi, because all my default values on the whole business partner object can be found in the same place, it is getting a bit strange to: first still enhance the view and context node class, adjust the visibility of the typed_context, call the badi and do all kind of checks to assure that you are in the right view/context node, where this all is faster and more lean and mean when done directly in the get_<attribute_name> method on a context node.
    Anyone who wants to give there opinion on this?
    Regards,
    Martijn.

    Cameron,
    Unfortunately you cannot pass the Account and Contact name before saving the record. Post default tries to capture the name just before the record gets saved, but as the record is yet to be created, the relationship wont exist and only the respective id fields will have values. If you try using account id/ contact id it will work else just pass the time stamp in the name field which will make sure there is some value when the record is saved. later in the back end you might need WS to update the field values.

Maybe you are looking for