5 Replies Latest reply: Mar 29, 2013 1:40 PM by 946699 RSS

    How to find particular instance in XML during overflow situation

    946699
      Hi,

      I have an XML with repetitive data. I have a requirement to display the particular instance of data. For example, I should display DailyBenefitAmount for second instance which is 150.00 as per the sample XML given below.

      I have read in Documaker documentation stating it can be mapped to XDD and with the below syntax to find the instance.
      Syntax: ?("XDD_NAME", #instance)

      So I have mapped my XML to XDD as ?("DailyBenefitAmount") and I used the ?("DailyBenefitAmount" , 2) in my DAL script, but no luck and this is not working.

      Can somebody throw some light how to handle this requirement.

      XML Sample

      <Rider id="Rider_1">
      <RiderCode>TERM </RiderCode>
      <DailyBenefitAmount>75.00</DailyBenefitAmount>
      <BenefitCode>ALF </BenefitCode>
      <ModalPremAmt>65.15</ModalPremAmt>
      </Rider>
      <Rider id="Rider_1">
      <RiderCode>TERM </RiderCode>
      *<DailyBenefitAmount>150.00</DailyBenefitAmount>*
      <BenefitCode>ALT </BenefitCode>
      <ModalPremAmt>65.15</ModalPremAmt>
      </Rider>
      <Rider id="Rider_1">
      <RiderCode>TERM </RiderCode>
      <DailyBenefitAmount>300.00</DailyBenefitAmount>
      <BenefitCode>NHC </BenefitCode>
      <ModalPremAmt>65.15</ModalPremAmt>
      </Rider>
        • 1. Re: How to find particular instance in XML during overflow situation
          Krishna61
          Hi,

          Try using GetData function instead of ?.

          Syntax: Getdata(SearchMask,Occurence)

          For your example, search mask would be Xpath for the dailybenefitamount field.

          Getdata("!/Rider/DailyBenefitAmount 1,5",1)

          For first occurence use "0" in second argument, second occurence use "1" and so on.

          Here "5" is the length of field value which needs to be extracted from xml.

          Thanks,
          Sai krishna
          • 2. Re: How to find particular instance in XML during overflow situation
            user9976634
            XML Xpath statements can be tricky when trying to deal with occurrences. In your example, where you might think of this as the second occurrence of DailyBenefitAmount it is really the "first" DailyBenefitAmount of the second occurrence of Rider that I think you want. So, the Xpath statement is more like this:

            //Rider[2]/DailyBenefitAmount

            Now, you probably don't want to have a specific XPath statement per occurrence you might want to retrieve. To get the occurrence to apply at the right level, you need to be able to be able to specify where the occurrence should apply within the XPath. This is accomplished using **** inside the brackets.

            //Rider[****]/DailyBenefitAmount

            When this XPath is executed, the occurrence value will substitute into the desired node level and return the appropriate value.
            • 3. Re: How to find particular instance in XML during overflow situation
              946699
              Thanks Sai, We tried as you per your suggestion. We are not successful in finding the particular occurence using Gendata(Mask,Occurence).
              • 4. Re: How to find particular instance in XML during overflow situation
                user9976634
                It's unfortunate that you did not get expected results. It might be helpful if you could provide more details on exactly what you have tried and any results (erroneous or not) that you received. Despite the popularity of XML as a means of transferring data, XML XPath is very syntax sensitive - and that has nothing to do with Documaker in general.
                In the past, I've found that it can be helpful to have an XPath tool - like XMLSpy - where you can try out specific searches to see what results are returned. Now it is true that an outside tool is not going to know about the [****] syntax that Documaker allows for substituting occurrence values. However, you can test specific XPath values within the bracket until you learn what will return your expected results and then try to transfer that syntax into Maker.
                • 5. Re: How to find particular instance in XML during overflow situation
                  946699
                  Thank You very Much user9976634 ! Finally after playing with the placement of counter [****] in Xpath it worked.