1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libxml2dom/svg.py Mon Jan 08 23:23:23 2007 +0000
1.3 @@ -0,0 +1,77 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +SVG-specific document support.
1.8 +
1.9 +Copyright (C) 2007 Paul Boddie <paul@boddie.org.uk>
1.10 +
1.11 +This library is free software; you can redistribute it and/or
1.12 +modify it under the terms of the GNU Lesser General Public
1.13 +License as published by the Free Software Foundation; either
1.14 +version 2.1 of the License, or (at your option) any later version.
1.15 +
1.16 +This library is distributed in the hope that it will be useful,
1.17 +but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.19 +Lesser General Public License for more details.
1.20 +
1.21 +You should have received a copy of the GNU Lesser General Public
1.22 +License along with this library; if not, write to the Free Software
1.23 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
1.24 +"""
1.25 +
1.26 +import libxml2dom
1.27 +from libxml2dom.macrolib import *
1.28 +from libxml2dom.macrolib import \
1.29 + createDocument as Node_createDocument, \
1.30 + parseString as Node_parseString, parseURI as Node_parseURI, \
1.31 + parseFile as Node_parseFile, \
1.32 + toString as Node_toString, toStream as Node_toStream, \
1.33 + toFile as Node_toFile
1.34 +
1.35 +class SVGImplementation(libxml2dom.Implementation):
1.36 +
1.37 + "Contains an SVG-specific implementation."
1.38 +
1.39 + def get_node(self, _node, context_node):
1.40 + if Node_nodeType(_node) == context_node.ELEMENT_NODE and \
1.41 + Node_namespaceURI(_node) == "http://www.w3.org/2000/svg" and \
1.42 + Node_localName(_node) == "svg":
1.43 +
1.44 + return SVGElement(_node, self, context_node.ownerDocument)
1.45 + else:
1.46 + return libxml2dom.Implementation.get_node(self, _node, context_node)
1.47 +
1.48 +class SVGElement(libxml2dom.Node):
1.49 +
1.50 + "An SVG-specific top-level element."
1.51 +
1.52 + NAV_AUTO = 1
1.53 + NAV_NEXT = 2
1.54 + NAV_PREV = 3
1.55 + NAV_UP = 4
1.56 + NAV_UP_RIGHT = 5
1.57 + NAV_RIGHT = 6
1.58 + NAV_DOWN_RIGHT = 7
1.59 + NAV_DOWN = 8
1.60 + NAV_DOWN_LEFT = 9
1.61 + NAV_LEFT = 10
1.62 + NAV_UP_LEFT = 11
1.63 +
1.64 +def parse(stream_or_string, html=0):
1.65 + return libxml2dom.parse(stream_or_string, html, default_impl)
1.66 +
1.67 +def parseFile(filename, html=0):
1.68 + return libxml2dom.parseFile(filename, html, default_impl)
1.69 +
1.70 +def parseString(s, html=0):
1.71 + return libxml2dom.parseString(s, html, default_impl)
1.72 +
1.73 +def parseURI(uri, html=0):
1.74 + return libxml2dom.parseURI(uri, html, default_impl)
1.75 +
1.76 +# Single instance of the implementation.
1.77 +
1.78 +default_impl = SVGImplementation()
1.79 +
1.80 +# vim: tabstop=4 expandtab shiftwidth=4