Leave feedback
  • Question

    XPath Expression

Enter a new topic
  • Roberto Avalos Roberto Avalos StreamServe Employee
    0 likes 2341 views


    I am trying to extract the last child value of a block in an XML. The XML is very simple.


    My expectation was that a simple xpath would return the value but it didn't




    I have also tried to use the following functions to know at least how many ChildFields are


    This last one seems to work if ChildField was a block.


    Any hint would be appriated



    Friday 22 July, 2011
  • Roberto Avalos Roberto Avalos StreamServe Employee

    I have tried the following but it only displays the first ocurrence of ChildField

    stEvalXPath("/data/message/Block1[1]/ChildField[1]"); //this retrieves data

    stEvalXPath("/data/message/Block1[1]/ChildField[2]"); //this DOES NOT retrieves data, just an empty space despite my example has 4 child fields. :(

    Friday 22 July, 2011
  • David Bares David Bares OpenText Employee Administrator StreamServe Employee

    I believe it can only run if the ChildField is a block.

    You cannot have more fields of the same name in one block.

    If ChildField was a block, you need to have some field to hold the value. E.g. ChildFieldValue.

    stEvalXPath("/data/message/Block1[1]/ChildField[last()]/ChildFieldVal ue") should return the value of last ChildField of the first Block1 (if available) or empty string (if not available).

    You should use the -wsin server option to dump your message structure or use stMsgSaveToFile() StoryTeller function to dump the XML instance that StoryTeller works with.

    Quite often you can see that the data dump is not "as expected". Then you need to change your message definition in event tool.

    Monday 25 July, 2011
  • Roberto Avalos Roberto Avalos StreamServe Employee

    Hi David,

    Thanks for the info. I know for a fact what the xml looks like and it is the way i described it.

    Actually, i am being passed that XML structure from SAP. In Story teller I have a repeater that displays all the values of Child Fields in a table and that works well. However in another section of the document, I am required to extract the last value of childField and display it. The problem is that this actually happens before i display the actual table.

    So I thought one way of doing it is to have an extra repeater that is invisible that loops through all the block and extracts the last value. This is not my prefered method but If extracting the last value of childField is not possible using an XPath expression I may have to get that xml fixed by SAP or use the method I did.

    Please let me know what you think,




    Tuesday 26 July, 2011
  • Stefan Cohen Stefan Cohen StreamServe Employee Administrator


    The xpath in StoryTeller references the strs message, not the source xml as sent from SAP. Please dump your message structure to file using either of the methods David described and post it here (rememeber to remove any sensiteve data first). That will alow us to help you.


    Wednesday 27 July, 2011