Witam!
Szanowni forumowicze, dzisiaj napotkał mnie problem z którym nie potrafię sobie poradzić.
A mianowicie, próbuję dokonać utworzenie drzewa XLM (parsowania). Natomiast podczas tworzenia struktury
jak poiżej :
def build_create_report(self):
'''
Returns: An lxml.etree.Element object
'''
oadr = ElementMaker(namespace=self.ns_map['oadr'], nsmap=self.ns_map)
pyld = ElementMaker(namespace=self.ns_map['pyld'], nsmap=self.ns_map)
ei = ElementMaker(namespace=self.ns_map['ei'], nsmap=self.ns_map)
xcal = ElementMaker(namespace=self.ns_map['xcal'], nsmap=self.ns_map)
payload = oadr.oadrCreateReport(
pyld.requestID(str(uuid.uuid4())),
oadr.oadrReportRequest(
ei.reportRequestID('RR_54321'),
ei.reportSpecifier(
ei.reportSpecifierID('RS_12345'),
xcal.granularity(
xcal.duration('PT0M'),
),
ei.reportBackDuration('PT0M'),
ei.reportInterval(
xcal.properties(
xcal.dtstart(
xcal.date-time('2015-07-17'),
),
xcal.duration(
xcal.duration('PT2H'),
),
),
),
ei.specifierPayload(
ei.rID('123'),
ei.readingType('x-notApplicable'),
),
ei.specifierPayload(
ei.rID('124'),
ei.readingType('x-notApplicable'),
),
),
),
ei.venID(self.ven_id),
)
return payload
oraz wywołaniu
req = urllib2.Request(register_uri, etree.tostring(payload), dict(DEFAULT_HEADERS))
Powinienem otrzymać
<pyld:requestID>REQ_12345</pyld:requestID>
<oadr:oadrReportRequest>
<ei:reportRequestID>RR_54321</ei:reportRequestID>
<ei:reportSpecifier>
<ei:reportSpecifierID>RS_12345</ei:reportSpecifierID>
<xcal:granularity>
<xcal:duration>PT0M</xcal:duration>
</xcal:granularity>
<ei:reportBackDuration>PT0M</ei:reportBackDuration>
<ei:reportInterval>
<xcal:properties>
<xcal:dtstart>
<xcal:date-time>2001-12-17T09:30:47Z</xcal:date-time>
</xcal:dtstart>
<xcal:duration>
<xcal:duration>PT2H</xcal:duration>
</xcal:duration>
</xcal:properties>
</ei:reportInterval>
<ei:specifierPayload>
<ei:rID>123</ei:rID>
<ei:readingType>x-notApplicable</ei:readingType>
</ei:specifierPayload>
<ei:specifierPayload>
<ei:rID>124</ei:rID>
<ei:readingType>x-notApplicable</ei:readingType>
</ei:specifierPayload>
</ei:reportSpecifier>
</oadr:oadrReportRequest>
<ei:venID>VEN_123</ei:venID>
Natomiast otrzymuję błąd postaci :
NameError: global name 'time' is not defined
W strukturze XML występuje nazwa xcal:**date-time**
I to w tym miejscu interpreter pythona zwraca błąd.
Czy ktoś spotkał się z podobnym problemem ?