2

I'm new to WSO2 Data Services Server and I trying to figure out how to get complex element types working correctly with the web scraper. Using the interface I seem to be able to define the object, but I'm not sure how to use it once it is defined. Below is the Data Service XML...

<data name="ComplexTypeExample">
   <description>A Description</description>
   <config id="GetPrices">
      <property name="web_harvest_config">./samples/resources/GetPrices.xml</property>
   </config>
   <query id="getSonyPrices" useConfig="GetPrices">
      <scraperVariable>priceInfoSony</scraperVariable>
      <result element="CameraInfo" rowName="Record">
         <element column="Pic" name="Pic" xsdType="string"/>
         <element column="Desc" name="Desc" xsdType="string"/>
         <element name="Inventory" namespace="">
            <element name="Item" namespace="">
               <element column="Grade" name="Grade" xsdType="string"/>
               <element column="Price" name="Price" xsdType="string"/>
            </element>
         </element>
      </result>
   </query>
   <operation name="getSonyPricesOperation">
      <description>Gets prices of KM/Sony cameras</description>
      <call-query href="getSonyPrices"/>
   </operation>
</data>

What I am trying to do is figure out how to get the Inventory element to be an array of Item types. Something like this...

   <Record>
     <Pic>Camera.jpg</Pic>
     <Desc>A camera made by some company</Desc>
     <Inventory>
        <Item>
            <Grade>Good</Grade>
            <Price>$200</Price>
        </Item>
        <Item>
            <Grade>Not So Good</Grade>
            <Price>$100</Price>
        </Item>
        <Item>
            <Grade>Broken</Grade>
            <Price>$10</Price>
        </Item>
     </Inventory>
   </Record>

Can anyone provide some hints as to where I'm going wrong?

poohdedoo
  • 1,258
  • 1
  • 18
  • 42
Rick Sarvas
  • 769
  • 10
  • 20

1 Answers1

1

Looks like you have done your complex element mapping correctly according to your result set .. Are you having trouble scraping the values? If so you have to provide us with the scraping configuration, and also you have to write the xslt file also according to your complex elements.

Please refer the following guide for web scraping

poohdedoo
  • 1,258
  • 1
  • 18
  • 42
  • Actually, the problem is that element mapping I provided above does not work. My issue is not that I have a problem picking the correct elements from the HTML - that I did over the weekend. My problem is that I can't make a complex element that works besides the initial result element. In the end I finally gave up and just concatenated the Grade and Price key pairs into comma separated values within a single element. Not ideal, but it did work. – Rick Sarvas Nov 05 '13 at 00:15