Esempio n. 1
0
    def Unmarshall(self, node):
        """Extracts the content of the node to an object.

    Args:
      node: The XML node to extract data from.

    Returns:
      The object representation of the node.
    """

        obj = {}
        obj[COMMENT_KEY] = GetCommentsForNode(node)

        if not node.firstChild:
            return obj
        text = node.firstChild.nodeValue
        obj[TEXT_KEY] = '\n\n'.join(pretty_print_xml.SplitParagraphs(text))

        # TextNode shouldn't have any child.
        unexpected = GetUnexpectedChildren(node, set())
        if unexpected:
            raise ValueError("Unexpected children: %s in <%s> node" %
                             (','.join(unexpected), self.tag))

        return obj
Esempio n. 2
0
  def Unmarshall(self, node):
    """Extracts the content of the node to an object.

    Args:
      node: The XML node to extract data from.

    Returns:
      The string content of the node.
    """
    if not node.firstChild:
      return ''
    text = node.firstChild.nodeValue
    return '\n\n'.join(pretty_print_xml.SplitParagraphs(text))
Esempio n. 3
0
  def Unmarshall(self, node):
    """Extracts the content of the node to an object.

    Args:
      node: The XML node to extract data from.

    Returns:
      The object representation of the node.
    """

    obj = {}
    obj[COMMENT_KEY] = GetCommentsForNode(node)

    if not node.firstChild:
      return obj
    text = node.firstChild.nodeValue
    obj[TEXT_KEY] = '\n\n'.join(pretty_print_xml.SplitParagraphs(text))

    return obj