3 Replies Latest reply on Dec 7, 2012 3:42 PM by Ashutosh Singh

    Get Attribute Value

      I am writing a BPEL component that interacts with a backend web service that returns an escaped string. This string could be a couple of different types of XML. The header for each xml type is the same. The root element is always a <BATCH> element that contains an TYPE attribute. I need to perform different functions based which type of XML is returned. Is there Java embedded function that will parse the XML for me and return the TYPE attribute value?
        • 1. Re: Get Attribute Value
          Ashutosh Singh
          Yes you can fetch value of attribute.
          You have to use @ operator for that. If you want, you can use expression builder also to fetch attribute in BPEL.

          In your scenario you can do below things.

          1: Take output string and parse that using below expression

          ora:parseEscapedXML(stirng output)

          2: Copy this to some other variable which can hold this xml strucutre, say Var_XML
          3: Then you can use expression similar to below given to fetch attribute

          bpws:getVariableData('Var_XML','part','xpath of the element/@DOJ')

          @ operator allows you to fetch attribute at a given xpath.

          I hope this is helpful.

          • 2. Re: Get Attribute Value
            Thank you for the response.

            What type would Var_XML be? This is were I am having the difficulty. I have used parseXML before to parse a string to a speicified schema type. The problem I am running into is I am trying to determine what type the XML is based on the input. Therefore I do not know what type I would make the Var_XML variable in your example.
            • 3. Re: Get Attribute Value
              Ashutosh Singh
              That is very easy. Create a canonical schema for your possible result xmls. This canonical should contain all possible combinations of result strings.
              Once your canonical schema is ready. You can copy your output variable to corresponding part of your canonical schema.

              Just make sure you use proper logic while doing this copy operations in canonical schema otherwise you will get exception.You can use switch activity to identify logical points.