class ItemXmlParser(base.BaseXmlParser):
    __namespaces__ = {'aw': 'http://www.adventure-works.com'}

    product_name = base.ValueField(".//aw:ProductName")
    part_number = base.ValueField("./@aw:PartNumber")
    quantity = base.ValueField(".//aw:Quantity")
    us_price = base.ValueField(".//aw:USPrice")
class PurchaseOrderXmlParser(base.BaseXmlParser):
    order_date = base.DateTimeField('@OrderDate')
    address_shipping = base.ObjectField("Address[@Type='Shipping']",
                                        AddressXmlParser)
    address_billing = base.ObjectField("Address[@Type='Billing']",
                                       AddressXmlParser)
    delivery_notes = base.ValueField("DeliveryNotes")
    items = base.ListObjectField("Items/Item", ItemXmlParser)
class PurchaseOrderXmlParser(base.BaseXmlParser):
    address_shipping = base.ObjectField(".//aw:Address[@aw:Type='Shipping']",
                                        AddressXmlParser)
    address_billing = base.ObjectField(".//aw:Address[@aw:Type='Billing']",
                                       AddressXmlParser)
    delivery_notes = base.ValueField(".//aw:DeliveryNotes")
    items = base.ListObjectField(".//aw:Item", ItemXmlParser)
    customer1 = base.ObjectField(".//aw:customer",
                                 Customer,
                                 default=Customer())
    customer2 = base.ObjectField(".//aw:customer", Customer, strict=True)
class PurchaseOrderWithNotFoundFields(base.BaseXmlParser):
    order_date = base.DateTimeField('@orderdate')
    order_date_default = base.DateTimeField('@orderdate',
                                            default=datetime(1970, 1, 1))
    order_date_empty = base.DateTimeField('@EmptyDate',
                                          default=datetime(1970, 1, 1))
    address_shipping = base.ObjectField("address[@Type='Shipping']",
                                        AddressXmlParser)
    address_billing = base.ObjectField("address[@Type='Billing']",
                                       AddressXmlParser)
    delivery_notes = base.ValueField("deliveryNotes")
    items = base.ListObjectField("items/Item", ItemXmlParser)
class AddressXmlParser(base.BaseXmlParser):
    name = base.ValueField("Name")
    city = base.ValueField("City")
class ItemXmlParser(base.BaseXmlParser):
    product_name = base.ValueField("ProductName")
    part_number = base.ValueField("@PartNumber")
    quantity = base.ValueField("Quantity", pytype=int)
    us_price = base.ValueField("USPrice", pytype=float)
Ejemplo n.º 7
0
class Address(base.BaseXmlParser):
    name = base.ValueField(".//aw:Name")
    city = base.ValueField(".//aw:City")
Ejemplo n.º 8
0
 class Address(base.BaseXmlParser):
     name = base.ValueField("Name")
     street = base.ValueField("Street")
     city = base.ValueField("City")
class Customer(base.BaseXmlParser):
    name = base.ValueField(".//aw:Customer")