Announcement Announcement Module
Collapse
No announcement yet.
parsing XPaths for node elements gives same element value Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • parsing XPaths for node elements gives same element value

    Hi,

    I have a problem which I think is something to do with my schema or how I get the Element value of a set of nodes.

    My schema generates the wsdl and allows me to make a request for a set of values which are 1 or more:

    <Addresses>
    <Contact>
    <Details>
    <ContactName>fred</ContactName>
    ..............
    </Details>
    </Contact>
    <Contact>
    <Details>
    <ContactName>john</ContactName>
    ..............
    </Details>
    </Contact>
    </Addresses>

    Everything works fine, my end point gets invoked as it should and I can create a Contact object with the values populated as expected. However all the contacts have the values of the first <Contact>.

    I am calling selectNodes and iterating over the elements, then calling valueOf using the XPath object of those Element objects.

    Code:
    List contacts = this.contact.selectNodes(addressRequest);
    
     for(Object contactObj : contacts) {
                Element contactElement = (Element)contactObj;
                Contact contact = new Contact(); 
                contact.setName(this.contactName.valueOf(contactElement));
    }
    If I make the request with more than one <Contact> the loop iterates over all those objects but each Contact object has the values from the first <Contact>

    contactName is the XPath declaration in the end point constructor which has the schema name space added, like this:

    Code:
    contactName = XPath.newInstance("//myTNS:ContactName");
    contactName.addNamespace(namespace)
    Can anyone see why each time I call contactName.valueOf on each <Contact> Element I only get the first values in the set?

    Many thanks,

    John

  • #2
    Hi,

    I have returned to this problem but still can't solve it.

    Has anyone else encountered the same thing?

    Any help would be much appreciated.

    Many thanks

    John.

    Comment

    Working...
    X