XmlObject - set value of element with a particular attribute

Hi,
In a xmlObject I try to set the value of xml element with a particular attribute but it doesn't work
//get value of element with a particular attribute
var myValue = xmlObject.ELEMENTS.ELEMENT.(@category == "myCategory"))// works fine
//set value of element with a particular attribute
var myValue = "foo"
xmlObject.ELEMENTS.ELEMENT.(@category == "myCategory"))= myValue // doesn't work
Thanks for your help
Regards

Hi Dirk,
For example :
var xmlObject = new XML ( "<rootElement> <elements> <element category='foo1'>value1</element> <element category='foo2'>value2</element> <element category='foo3'>value3</element> </elements></rootElement>");
myValue = xmlObject.elements.element.(@category == "foo1");
$.writeln(myValue)// return value1
// Now I want modify value1 to value99 like this
xmlObject.elements.element.(@category == "foo1")= "value99"; //doesn't work
I hope I was clear in my explanation ;-)
Regards

Similar Messages

  • XPath to select elements with specific namespace attribute?

    To select all elements with a specific attribute, i can use
    //*[attribute::val1='true']for elements that look like
    <Name val1="true">hello</Name>But how can i select them, if the attribute has a namespace:
    <Name myns:val1="true">hello</Name>?

    If JDOM is used to parse a node with XPath, node namespace should be added to the XPath.
    XPath xpath=XPath.newInstance("/@myns:val1='true');                
      xpath.addNamespace("myns", "http://www.w3.org/2001/XMLSchema-Instance");

  • How to bind UI Element with Context Node Attribute Element

    Hi,
    I'm building my view dynamically in the wdDoModifyView method.
    Is it possible to bind a "TextView" element to a specific element of an attribute node?
    Scenario:
    Node_Employees
    |
    +- Attribute_Code
    |
    +- Attribute_Name
    Node Contents:
    Employees
    |
    +- Code: 1, Name: Employee 1
    |
    +- Code: 2, Name: Employee 2
    |
    +- Code: 3, Name: Employee 3
    I need to do something like binding a TextView UI element to the "Name" attribute of the element #2, what would result to show "Employee 2" on my view.
    How can I do this?
    Thanks in advance,
    Geraldo.

    Hi Saravanan,
    First I populate the context node and it won't change during view's lifecycle.  After that, I build my view and bind the TextView UI elements to the node context attributes elements.
    If the node has 10 elements, I will build 10 TextView UI elements and bind them to each attribute element.
    Regards,
    Geraldo Brígido.

  • Set values in ListBox with Javascript.

    Hello.
    I have a ListBox that can have multiple values (you can set this in Designer 7.1 by the way). I want to select 1, 2, x, values in this ListBox by script in Javascript. I can read these values like this:
    var a = xfa.resolveNode ("ListBox1.value").nodes;
    xfa.host.messageBox (a.item(0).value);
    But how can I set the values?
    Another question: Is it possible to get these values as an array or do I have to parse the value above to get the values?
    /Per

    DropDownList2.clearItems(); <br />DropDownList2.rawValue =""; <br />//Add the new ones with an indexed boundItem <br />var myIndex = this.boundItem(xfa.event.change); <br />var cities = new Array( <br />  new Array("New Orleans", "NYC", "L.A."), <br />  new Array("Paris", "Lyon", "Marcheilles"), <br />  new Array("London", "Liverpool", "Newcastle", "Manchester"), <br />  new Array("Tokyo", "Kyoto", "Hiroshima"), <br />  new Array("Bremen", "Hannover", "Hamburg", "Berlin")); <br />for (i=0;i<cities[myIndex].length;i++){ DropDownList2.addItem(cities[myIndex][i] , String(i)); } <br />/Ulf DTP-tjänst

  • How to create an element with an ID attribute ?

    Hi,
    first i need to say i searched the web for ~one week now, and couldn't find any good solution.
    Lastly i searched into this forum and, unfortunaly, i couldn't find any good answers to the problem.
    Here are the reference :
    http://forum.java.sun.com/thread.jsp?forum=34&thread=290862 < it's exactly the pb, no answers
    http://forum.java.sun.com/thread.jsp?forum=34&thread=338022 < no answers
    http://forum.java.sun.com/thread.jsp?forum=34&thread=67747 < answer is false
    http://forum.java.sun.com/thread.jsp?forum=34&thread=67683 < same pb, wrong answer
    http://forum.java.sun.com/thread.jsp?forum=34&thread=470003 < a bit far form the initial subject
    so i'll be quick :
    - when you load ur xml DOM, u can use the 'getElementById()' method, and it works very well
    - but when u create a new Element, u can't use the simple 'setAttribute()' method because as said in the doc : "Because the DOM Core is not aware of attribute types, it treats all attribute values as simple strings, even if the DTD or schema declares them as having tokenized types.", therefore, the 'getElementById()' can't work with those newly created Element.
    - same pb arise when u try to modify an ID attribute...
    so, with my investigation, i found that u need to specify to the DOM that the attribute you just set is an 'ID'.
    and that's where i have problems, i tried creating EntityReference and binding that node to the attribute node, the element node and even to the Textnode but couldn't find anything to work...
    Here is my method (which doesn't work) :
    public void setIdAttribute(Element element,String nameAttribut, String dataAttribut)
                    System.out.println("setIdAttribute() : nameAttribut="+nameAttribut+" dataAtribut="+dataAttribut+" user="+element.toString()); //DEBUG
                    Attr attributRef = document.createAttribute(nameAttribut);
                    EntityReference er = document.createEntityReference(nameAttribut); //creating an Reference for the attribute named 'nameAttribut'
                    Text data = document.createTextNode(dataAttribut);
                    //link to the main DOM tree
                    attributRef.appendChild(data); //adding the String data
                    attributRef.appendChild(er); //...then telling DOM that the attribute 'nameAttribut' is an ID
                    //at last linking the attribute node
                    element.setAttributeNode(attributRef);
            }I'm totally lost :/ (help !)
    AciD

    After thinking about it some more, I find that adding a setIdAttribute() method in a DOM level 3 conformant way while at the same time keeping it independent of a particular DOM implementation would take quite some effort. It's easier to add similar functionality into a Document wrapper along these lines:
    public class MyDocument implements Document {
       private Document _doc;
       private Map _eltsById = new TreeMap();
       public MyDocument(Document doc){
          _doc = doc;
       public Element getElementById(String id){
          Element foundElt = _doc.getElementById(id);
          if (foundElt == null)
             foundElt = (Element)_eltsById.get(id);
          return foundElt;
       public void setIdAttribute(String attrName, Element elt){
          String attrValue = elt.getAttribute(attrName);
          if (attrValue != null)
               _eltsById.put(attrValue, elt);
       //...implement all the other Document methods by forwarding to _doc
    test(){
       MyDocument myDoc = new MyDocument(parse(...));
       Element elt = myDoc.createElement(...);
       elt.setAttribute("id", "123");
       myDoc.getDocumentElement().appendChild(elt);
       myDoc.setIdAttribute("id", elt);
       Element foundElt = myDoc.getElementById("123");
       assert elt == foundElt;
    }Unfortunately this simple implementation breaks down if an ID attribute value is later changed, so this is probably a rather dirty hack.
    Some DOM implementations allow you to search for nodes using implementation specific methods or XPath. Oracle's XML does it like this:
    XMLDocument doc = parse(...);
    Element elt = (Element)doc.selectSingleNode("//*[@id='123']");
    Or like this with Xalan:
    CachedXPathAPI xpath = new CachedXPathAPI();
    Element elt = (Element)xpath.selectSingleNode(doc, "//*[@id='123']");
    The XPath based ways of searching for nodes have the benefit of not being dependent on schema validation in the first place (as the ID based mechanisms are). And of course you have many more search options than just attribute values. On the other hand XPath evaluation is hugely slower than most getElementById implementations if it doesn't use some kind of index. So if you want fast (that is index based) XPath queries for in memory XML data, you should probably look at something like XQEngine http://xqengine.sourceforge.net/
    -Alexander

  • Append XML elements with same name in an XML document

    Hi,
    I am using Oracle9i XMLDB utilities to modify an XML document stored in the database. I have a sample XML document like this in the database:
    <Person>
    <Address ID="1"> </Address>
    </Person>
    My task is to include a second <Address> element with a different attribute so that my XML document will become
    <Person>
    <Address ID="1"> </Address>
    <Address ID="2"> </Address>
    </Person>
    After creating the second element, I am using the function xmldom.appendChild() or xmldom.insertBefore() but they remove the first <Address> element and replace it with the second one. This is not what I want since I want both <Address> elements to be present.
    Could anyone please advise.
    Thanks.
    A. Dennis

    Please post your question [url http://forums.oracle.com/forums/forum.jsp?forum=154]here for quick response.
    thank you.
    Regards,
    Anupama
    [url http://otn.oracle.com/sample_code/]OTN Sample Code

  • How to set values to the structure containing a node with cardinality 0..n

    Hello.
    I 'm trying to set values for the node with cardinality 0..n. The node type is "Fields".
    <xsd:complexType name="Field">
       <xsd:sequence>
          <xsd:element name="fieldCode" type="xsd:string"></xsd:element>
          <xsd:element name="displayValue" type="xsd:string" minOccurs="0"></xsd:element>
       </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Fields">
       <xsd:sequence>
          <xsd:element name="field" type="tns:Field" minOccurs="0" maxOccurs="unbounded"></xsd:element>
       </xsd:sequence>
    </xsd:complexType>
    I  need to set several values for the element "fieldCode" but it has cardinality 0..1 and BPM does not allow it but I did not find any option about how to set values for the structure of type "Fields". Could you help me?
    Best regards,
    Timur Semenchuk

    Hi Marcus,
    If there is no way you could change the cardinality of the node, and thus it can contain 0..n items, I think you should create-and-add a new element programmatically.
    Since the collection can contain zero elements, I would add a 'new' button, which upon clicking adds one new element via:
    IYourNodeElement yourNodeElem = wdContext.nodeYourNode().createYourNodeElement();
    wdContext.nodeYourNode().addElement(yourNodeElem);
    Hope this explains a bit!
    Best,
    Robin van het Hof

  • Dynamic action with set value on date field

    Hi,
    I'm using APEX 4.02
    I'm trying to calculate the age based on the date of birth dynamically on a form. I'm trying to do this with a (advanced)dynamic action with set value.
    I'm able to get this kind of action working based on a number field etc, but NEVER on a date field.
    I've read all posts on this subject but so far no solution. Even if I try to simply copy the value over to another date field or typecast it to a string ( to_char function ) it does not work. So for me the problem seems to be in the source field being a date field.
    I've tried using the source value as is in a select statement :
    select :P33_GEBOORTEDATUM from dual;
    and also type casted based on the date format :
    select TO_DATE(:P33_GEBOORTEDATUM,'DD-MON-YYYY') from dual
    but still no luck.
    On the same form I don't have any issues as long as the calculation is based on number fields, but as soon as I start using dates all goes wrong.
    Any suggestions would be greatly appreciated. If you need any extra info just let me know.
    Cheers
    Bas
    b.t.w My application default date format is DD-MON-YYYY, maybe this has something to do with the issue .... ?
    Edited by: user3338841 on 3-apr-2011 7:33

    Hi,
    Create a dynamic action named "set age" with following values.
    Event: Change
    Selection Type: Item(s)
    Item(s): P1_DATE_OF_BIRTH
    Action: Set value
    Fire on page load: TRUE
    Set Type: PL/SQL Expression
    PL/SQL Expression: ROUND( (SYSDATE - :P1_DATE_OF_BIRTH)/365.24,0)
    Page items to submit: P1_DATE_OF_BIRTH
    Selection Type: Item(s)
    Item(s): P1_AGE
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • Shopping cart Issue with ( "Default settings:   Set values" ) link

    Hello SRM Gurus,
    I have an issue in shopping cart process:
    When creating a shopping cart, I am trying to change the u201CDelivery Address/Performanceu201D tab data through link u201CDefault settings:   Set valuesu201D, then add the items in to shopping cart and ordered. The change values are properly populating.  For example (Street/house number) .
    But when we re-creating the shopping cart,  the changed values are not populating  automatically (Itu2019s not updated in to master  table I guess) and  we need to  open the link u201CDefault settings:   Set valuesu201D  and  change the values again.
    So is this link (u201CDefault settings:   Set valuesu201D )  active only for that particular Shopping cart? Or is it missing to update the changed data in to master table?
    Because business wants, when changes happen through (u201CDefault settings:   Set valuesu201D) link, It should be update in to users master and when open next time the changed value should be populated.
    Is this standard behavior of shopping cart?
    Kindly let me know your comments.
    Thanks.
    Regards,
    Magesh.

    Hi Anubhav
    Thanks for the mail.
    Actually my issue is that,
    When creating new shopping cart, trying to change some values through "Default Settingsu201D will it be parentally stores the changed value into user master data? Or it is temporarily changes for that shopping cart alone?
    Because business wanted when changing the values in "Default Settingsu201D  the changed value should be appeared when creating shopping cart next time also..
    So I want to know that , What is the  standard behavior of u201Cdefault settingsu201D . Kindly let me know your experience.
    Thanks.
    Regards,
    Magesh Basavaraj.

  • Running SSIS Package from SQL Job - with Set Values, a string containing";"

    Can anybody help with this problem please?
    I’m using “set value” in SQL agent to pass in an email address to my SSIS package, if I put in a value of:
    [email protected]
    It works fine, but if I attempt to input multiple email addresses it fails
    [email protected];[email protected]
    It doesn’t appear to like the “;”.
    Any ideas anyone???
    BoroFC

    Hi Jamie, many thanks for the response.
    If I look at my command line table when Email = [email protected], it looks like:
    /SET "\package.Variables[EmailAddress].Value";"[email protected]" /REPORTING E
    If I change the value to “[email protected];[email protected]”, it looks like:
    /SET "\package.Variables[EmailAddress].Value";"\""" [email protected];"" [email protected] ""\"" /REPORTING E
    But the weird thing is, if I close the job properties window and re-open it again, I lose this line from my set values screen all together!!!
    Help ???
    BoroFC

  • A report that shows all the elements with their setting

    Hi
    Is there a way to write a report in discoverer which will show all the elements set up in Oracle with there settings e.g. are they taxable or niable etc.
    Alternatively is there a standard report in HRMS which would give the same results.
    Thanks in advance

    Not really as such. Taxable and Niable elements feed to the appropriate taxable or niable balances therefore, you will need to run a report against what elements are fed into these balances. I doubt that there will be anything as standard in teh pre shipped EUL's that will enable you to do this, however, for simple one of why don't you just call up teh balances in teh application and see what elemenst feed into them.
    Cheers
    Scott

  • Set value in af:query with value from method

    hello all
    i have problem, when they want set value in af:query (inputText) with value from method, how to do that?
    anyone help..?
    thx
    agungdmt

    Hi,
    are you facing this issue when you try to show few values on right side (selected list) of shuttle component.
    what is your usecase exactly ?

  • JAXB unmarshalling elements with xs:type explicitly set

    I am working with XML content where the XSD defines an element as being of a complexType (say "ParentType") but the content explicitly sets the element's xs:type attribute to an extension of that complexType (say "ChildType").
    As far as I can tell the XML is valid, but JAXB issues the following when unmarshalling:
    DefaultValidationEventHandler: [ERROR]: Unexpected element {}:child1
    javax.xml.bind.UnmarshalException: Unexpected element {}:child1
    Where <child1> is added via the extension.
    Is this a problem with JAXB or my XSD?
    (XSD and XML enclosed below)
    XSD ------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:complexType name="ParentType">
    <xs:sequence>
    <xs:element name="parent1" type="xs:string"/>
    <xs:element name="parent2" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ChildType">
    <xs:complexContent>
    <xs:extension base="ParentType">
    <xs:sequence>
    <xs:element name="child1" type="xs:string"/>
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    <xs:element name="root">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="child" type="ParentType"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    XML -----------------------
    <?xml version="1.0" encoding="UTF-8"?>
    <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="problem.xsd">
    <child xsi:type="ChildType">
    <parent1/>
    <parent2/>
    <child1/>
    </child>
    </root>

    JAXB doesn't handle OO schema design. I tried to do something similar where I defined a type called base and then defined that my document contained 1 or more base elements. Then I tried to unmarshall a document that contained elements that were of types extending from base. I ended up with the same issue.
    It seems that when the xjc compiler defines the classes it isn't smart enough to realize the element defined as parent could also contain a child element since child extends parent. Your XSD and XML are valid.
    I would think that JAXB should identify that because there is a type the extends the defined type, that an element of the sub-type might be subsituted i.e. check the actual type of the element in the XML before attempting to unmarshall it as the default type. It doesn't do that. I am not sure if this is as desinged, or a flaw in the implementation.

  • How can I find the element with the closest value to a calculated "target value" in a 1D array?

    Hello all,
    may be the following question is very simple, but I am relatively new in labview and it would be great if somebody could help me:
    I have a acquaried 1D array of data-points. Now, I have to find the element in this array which value is the closest to a calculated "target value".
    After finding the element with the value close to the "target value", I have to get the position of this element (i.e. the index) in the 1D array.
    Now, I have to use this index to find and extract the element at this position in an other 1D array.
    It would be very nice if somebody could help me with this problem.
    Thank you,
    beam

    Find attached a sample vi that you can modify.
    Attachments:
    select_target_value.vi ‏22 KB

  • Set value with XPath dynamically

    Dear All,
    I am wonder if the following is possiable with Set Value service using XPath, any *simple* workaround is also welcome too.
    If I have a variable myXML =
    <root>
    <item region="One">1</item>
    <item region="Two">2</item>
    </root>
    I can reference to /root/item[1] by:
    set /process/@myNum = 1
    set /process/@dummy  = /process_data/myXml/root/item[number(\process\@myNum)]
    But how can I access /root/item[@region="One"] ?
    I tried the following but all failed:
    1)
    set /process/@myString = @region="One"
    set /process/@dummy  = /process_data/myXml/root/item[string(\process\@myString)]
    2)
    set /process/@myString = One
    set /process/@dummy  = /process_data/myXml/root/item[@region='string(\process\@myString)']
    And are there any way to set a variable using template string? (i.e. You name is {$/process/@yourName$} )
    Regards
    Bill

    Bill,
    As the nature of dynamic xPath statements is very use-case dependant, there is not much in the way of documentation. However, I will forward this thread to the documentation team to see if there is anything that can be added in the future to make these types of questions covered in the docs.
    As for setting a variable by using a template, there is no way to do this in setValue service unfortunately. However, you can use the executeScript service in LC ES. This service allows you to write java code and have access to the LC ES APIs while in context of your process. If you go to http://help.adobe.com/en_US/livecycle/9.0/workbenchHelp/help.htm and look under Creating Processes Using LiveCycle Workbench ES2 / Service Reference / Execute Script you will find documentation about how ot use this service.
    http://help.adobe.com/en_US/livecycle/9.0/workbenchHelp/000580.html
    There is a method called replacePathExpressions(String aString) that is exposed by the patExecContext object. this method takes in a template like you are looking to use. Basically a string that contains some xPath expressions wrapped in {$ $}. I created a sample process (attached to this post) that has a process variable called templateString. I used a setValue service to set it's value to:
    "Your name is {$/process_data/@name$} and your address is {$/process_data/@address$}."
    Of course, I also have variables called "name" and "address" that I have tagged as input variables. Then I have the executeScript service with the following code (basically 3 lines of code with alot of comments):
    //Get the templateString process variable value.
    String template = patExecContext.getProcessDataStringValue("/process_data/@templateString");
    // Call the replacePathExpressions() method.
    // It is a built-in method that will look for all {$ $} variable text and process each xPath expression and replace them in the text.
    String result = patExecContext.replacePathExpressions(template);
    // Now, the result string contains all of the resolved xPath statements.
    // Let's set the process variable that will hold the result.
    patExecContext.setProcessDataStringValue("/process_data/@resultString",result);
    Now you can dynamically construct responses using template variables.
    Also, thanks to Florentin Wandeler for the tip on the replacePathExpressions() method.

Maybe you are looking for

  • How do I display a PDF file in Adobe from h:commandLink or h:outputLink

    I am looking to add a simple "Help" link on my header. The idea is to add an h:outputLink or h:commandLink component and when it is clicked, an existing PDF file will be displayed in the default (Adobe) viewer. Can anyone give me a simple example of

  • Export (exp) taking long time and reading UNDO

    Hi Guys, Oracle 9.2.0.7 on AIX 5.3 A schema level export job is scheduled at night. Since day before yesterday it has been taking really long time. It used to finish in 8 hours or so but yesterday it took around 20 hours and was still running. The sc

  • Graphics Card Driver Query

    hi i have seem people using the exact card as me when they use 3dmark they seem to have pure hardware accelration but i do not have this . How can i get it to be pure harware as that person with the exact specs is getting over 1000marks more than me.

  • Query language for XML documents

    Which is a better (efficiency in terms of memory management) query language for interacting with XML documents.The query language shouls support 'insert', 'delete', 'update' and 'select' commands. How fast is database as compared to XML ( database be

  • Migrating emails from Thunderbird: small IMAP mailbox size

    I recently got a MacBook Pro and now I want to move my emails from my former email client on a Windows XP PC, Thunderbird, to Mac Mail on the MacBook Pro (Mac OS X 10.6.2). I created the appropriate email account in Mac Mail, this part works fine. Bu