fnp
/
librarian.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changes in PDF: font, no cover, paragraph style
[librarian.git]
/
librarian
/
document.py
diff --git
a/librarian/document.py
b/librarian/document.py
index
acc80ae
..
462b1ba
100755
(executable)
--- a/
librarian/document.py
+++ b/
librarian/document.py
@@
-11,14
+11,16
@@
from .parser import SSTParser
class Document(object):
class Document(object):
- # Do I use meta_context?
def __init__(self, edoc, meta_context=None):
self.edoc = edoc
def __init__(self, edoc, meta_context=None):
self.edoc = edoc
-
root_elem = edoc.getroot()
root_elem = edoc.getroot()
+ # Do I use meta_context?
if meta_context is not None:
root_elem.meta_context = meta_context
if meta_context is not None:
root_elem.meta_context = meta_context
+ self.validate()
+ def validate(self):
+ root_elem = self.edoc.getroot()
if not isinstance(root_elem, Section):
if root_elem.tag != SSTNS('section'):
if root_elem.tag == 'section':
if not isinstance(root_elem, Section):
if root_elem.tag != SSTNS('section'):
if root_elem.tag == 'section':
@@
-34,9
+36,7
@@
class Document(object):
raise ValueError("Invalid root element. Found '%s', should be '%s'" % (
root_elem.tag, SSTNS('section')))
else:
raise ValueError("Invalid root element. Found '%s', should be '%s'" % (
root_elem.tag, SSTNS('section')))
else:
- raise ValueError("Invalid class of root element. "
- "Use librarian.parser.SSTParser.")
- #print etree.tostring(self.edoc.getroot())
+ raise ValueError("Invalid class of root element. Use librarian.parser.SSTParser.")
@classmethod
def from_string(cls, xml, *args, **kwargs):
@classmethod
def from_string(cls, xml, *args, **kwargs):