- self._doc = bindery.parse(self._file, prefixes=PREFIXES)
- if self._doc.xml_select(u'/db:article/db:info/db:title'):
- self._title = unicode(self._doc.article.info.title)
- if self._doc.xml_select(u'/db:article/db:info/db:titleabbrev'):
- self._menu = unicode(self._doc.article.info.titleabbrev)
-
- dirname = os.path.dirname(self._file)
- code = self._doc.xml_select(u"//xi:include[@parse='text']")
- if code:
- for c in code:
- (p, ext) = os.path.splitext(c.href)
- if ext in valid_scripts:
- exe = []
- exe.append(os.path.join(os.path.abspath(dirname)+'/'+c.href))
- if c.xml_select(u"//xi:include[@accept-language]"):
- alang = c.xml_attributes[None, "accept-language"]
- exe.append("lang="+alang)
- if c.xml_select(u"//xi:include[@xpointer]"):
- exe.append("xptr="+c.xpointer)
- xml = subprocess.Popen(exe,stdout=subprocess.PIPE)
- xstr = bindery.parse(str(xml.stdout.read()))
- idp = c.xml_index_on_parent
- for x in xstr.xml_children:
- c.xml_parent.xml_insert(idp,x)
- c.xml_parent.xml_remove(c)
-
- for r in self._doc.xml_select(u"//db:link[@xl:href]"):
- rf = os.path.join(dirname,r.href)
- if os.path.isfile(rf):
- self._resources.append(rf)
- for i in self._doc.xml_select(u"//db:imagedata[@fileref]"):
- im = os.path.join(dirname,i.fileref)
- if os.path.isfile(im):
- self._resources.append(im)
- for i in self._doc.xml_select(u"//html:form[@action]"):
- pyscript = re.split('\.py',i.action,1)[0]+'.py'
- im = os.path.join(dirname,pyscript)
- if os.path.isfile(im):
- self._resources.append(im)
+ self._doc = Docbook(self._file)
+ (self._title, self._menu) = self._doc.title()
+ self._doc.expand_imageobjects()
+ self._doc.parse_xincludes()
+ self._doc.xinclude()
+ self._template = self._doc.role()
+ self._status = self._doc.status()
+ doc = self._doc.collect_links()
+ img = self._doc.collect_images()
+ vid = self._doc.collect_videos()
+ form= self._doc.collect_forms()
+ self._resources = doc + img + vid + form