示例#1
0
    def toxml(self, stylesheet="proviola.xsl"):
        frame_doc = Movie.toxml(self, stylesheet)
        # Entitites taken from Symbols.v in the SF notes.
        entity_map = {
            "nbsp": " ",
            "mdash": "—",
            "dArr": "⇓",
            "rArr": "⇒",
            "rarr": "→",
            "larr": "←",
            "harr": "↔",
            "forall": "∀",
            "exist": "∃",
            "exists": "∃",
            "and": "∧",
            "or": "∨",
            "Gamma": "Γ",
            "quot": """,
            "acute": "´",
        }

        entities = "\n".join([
            '<!ENTITY %s "%s">' % (key, entity_map[key]) for key in entity_map
        ])
        frame_doc.insert(1, Declaration("DOCTYPE movie [" + entities + "]"))
        scene_tree = Tag(frame_doc, "scenes")
        frame_doc.movie.append(scene_tree)

        for scene in self._scenes:
            scene_tree.append(scene.toxml(frame_doc))

        return frame_doc
示例#2
0
  def setUp(self):
    """ Sets up fixture. """
    self._target = NamedTemporaryFile(suffix = ".xml", delete = False)
    s = BeautifulStoneSoup()
    self._a = Tag(s, "a")
    self._frame = Coqdoc_Frame(command_cd = [self._a], command = "foo",
                               response = None)

    self._coqdoc_movie = Coqdoc_Movie()
    self._coqdoc_movie.addFrame(self._frame)
示例#3
0
    def toxml(self, doc):
        """ Convert this frame to XML. """
        frame_xml = Frame.toxml(self, doc)
        tag = Tag(doc, TAG_COQDOC)

        if self._command_coqdoc:
            map(tag.append, self._command_coqdoc)

        frame_xml.append(tag)

        return frame_xml
示例#4
0
    def toxml(self, doc):
        frameElement = Tag(doc, TAG_FRAME)
        frameElement[TAG_ID] = self.getId()
        frameElement.append(
            self.createTextElement(doc, TAG_CMD, self.getCommand()))

        if self._response:
            frameElement.append(
                self.createTextElement(doc, TAG_RES, self.getResponse()))

        return frameElement
示例#5
0
    def toxml(self, stylesheet="proviola.xsl"):
        """ Marshall the movie to an XML document. """
        doc = BeautifulStoneSoup()
        docType = ProcessingInstruction("xml version='1.0' encoding='utf-8'")
        doc.append(docType)

        styleSheetRef = ProcessingInstruction(
            'xml-stylesheet type="text/xsl" href="%s"' % stylesheet)

        doc.append(styleSheetRef)

        movie = Tag(doc, "movie")
        doc.append(movie)

        film = Tag(doc, TAG_FILM)
        movie.append(film)

        for frame in self._frames:
            film.append(frame.toxml(doc))

        return doc
示例#6
0
  def toxml(self, document):
    """ Create an XML subtree out of this scene, as generated in document.
    """
    element = Tag(document, "scene")

    for key, value in self._attributes:
      element[key] = value


    element["scenenumber"] = self._no
    element["class"] = self._type

    for sub in self._subscenes:
      element.append(sub.get_reference(document))

    return element
示例#7
0
    def get_reference(self, document):
        """ A Frame is referred to by its identifier. """

        ref = Tag(document, "frame-reference")
        ref[TAG_ID] = self.getId()
        return ref
示例#8
0
 def createTextElement(self, doc, elementName, contents):
     """ Convenience method for creating text-containing nodes in doc """
     contents = contents or ""
     element = Tag(doc, elementName)
     element.append(escape(contents))
     return element