def parse_comments(document, xmlcontent):
    """Parse comments document.

    Comments are defined in file 'comments.xml'
    """

    comments = etree.fromstring(xmlcontent)
    document.comments = {}

    for comment in comments.xpath('.//w:comment', namespaces=NAMESPACES):
        # w:author
        # w:id
        # w: date
        comment_id = comment.attrib[_name('{{{w}}}id')]

        comm = doc.CommentContent(comment_id)
        comm.author = comment.attrib.get(_name('{{{w}}}author'), None)
        comm.date = comment.attrib.get(_name('{{{w}}}date'), None)

        comm.elements = [parse_paragraph(document, para) for para in comment.xpath('.//w:p', namespaces=NAMESPACES)]

        document.comments[comment_id] = comm
def parse_comments ( document , xmlcontent ) : comments = etree . fromstring ( xmlcontent ) document . comments = { } for comment in comments . xpath ( './/w:comment' , namespaces = NAMESPACES ) : comment_id = comment . attrib [ _name ( '{{{w}}}id' ) ] comm = doc . CommentContent ( comment_id ) comm . author = comment . attrib . get ( _name ( '{{{w}}}author' ) , None ) comm . date = comment . attrib . get ( _name ( '{{{w}}}date' ) , None ) comm . elements = [ parse_paragraph ( document , para ) for para in comment . xpath ( './/w:p' , namespaces = NAMESPACES ) ] document . comments [ comment_id ] = comm
Parse comments document.

    Comments are defined in file 'comments.xml'