1.1 --- a/XSLTools/XMLCalendar.py Sun Aug 28 23:45:07 2005 +0000
1.2 +++ b/XSLTools/XMLCalendar.py Mon Aug 29 18:28:06 2005 +0000
1.3 @@ -22,20 +22,23 @@
1.4
1.5 # XML production functions.
1.6
1.7 -def write_calendar_for_month(doc, year, month):
1.8 +def write_month_to_document(doc, root, year, month):
1.9 weeks = monthcalendar(year, month)
1.10 - month_element = doc.childNodes[-1].appendChild(doc.createElement("month"))
1.11 - for dates in weeks:
1.12 + month_element = root.appendChild(doc.createElement("month"))
1.13 + month_element.setAttribute("number", str(month))
1.14 + month_element.setAttribute("year", str(year))
1.15 + for numbers in weeks:
1.16 week_element = month_element.appendChild(doc.createElement("week"))
1.17 - for date in dates:
1.18 + for number in numbers:
1.19 day_element = week_element.appendChild(doc.createElement("day"))
1.20 - if date != 0:
1.21 - day_element.setAttribute("date", "%04d%02d%02d" % (year, month, date))
1.22 + if number != 0:
1.23 + day_element.setAttribute("date", "%04d%02d%02d" % (year, month, number))
1.24 + day_element.setAttribute("number", str(number))
1.25
1.26 def get_calendar_for_month(year, month):
1.27 - d = libxml2dom.createDocument(None, "calendar", None)
1.28 - write_calendar_for_month(d, year, month)
1.29 - return d
1.30 + doc = libxml2dom.createDocument(None, "calendar", None)
1.31 + write_month_to_document(doc, doc.childNodes[-1], year, month)
1.32 + return doc
1.33
1.34 if __name__ == "__main__":
1.35 import sys