Loading Data from an XML File


#1

I am testing to load data from an XML file. I prepared a simple XML. It looks like this.

20%20PM

In my local environment, I have defined an entity type, a canonical and transform, I have also defined a SourceCollention for my canonical.

Entity type:

entity type LightBulbXML schema name 'LGHT_BLB_XML' {

  bulbType:     string
  wattage:      decimal
  startDate:    datetime
  manufacturer: string
}

Canonical:

type CanonicalLightBulbXML mixes Canonical<CanonicalLightBulbXML> {
 // This represents the manufacturer of a {@link LightBulbXML}
 Manufacturer: string
 // This represents the bulb type of a {@link LightBulbXML}
 BulbType: string
 // This represents the wattage of a {@link LightBulbXML}
 Wattage: decimal
 // This represents the id of a {@link LightBulbXML}
 SN: string
 // This represents the start date of a {@link LightBulbXML}
 StartDate: datetime
}

Transform:

type TransformCanonicalLightBulbXMLToLightBulbXML mixes LightBulbXML transforms
CanonicalLightBulbXML {
 id: ~ expression "SN"
 manufacturer: ~ expression "Manufacturer"
 bulbType: ~ expression "BulbType"
 wattage: ~ expression "Wattage"
 startDate: ~ expression "StartDate"
}

I did the provisioning, then I tried to upload an xml file from the curl command, I changed the content-type to “application/xml”.

curl -v -H "Content-Type: application/xml" -X PUT --data-binary @/Users/erickalanis/Documents/C3IOT/Training/test.xml http://localhost:8080/import/1/nu/dev/CanonicalLightBulbXML/test.xml -u BA -p

Although, the DataUploadLog and the DataProcessLog have status SUCCESS, the data loaded into my type is not what it was in the XML and not the number or records I would expect.

Do I need to do any change in the transformation?
Is there any XML format that I need to follow?
Do I need to Mix an XML type for my Canonical or Transform?
can I use the c3.util.xml for this case?