class_docstr: This class can read Abbyy documents out of a directory
code: def parseXMLfile(self, imgfile, xmlfile):
      # Reads the xml file with the xml.etree.ElementTree package
      try:
          tree = ET.parse(xmlfile)
      except ET.ParseError as e:
          raise XMLParseError(
              "The xml file '"
              + xmlfile
              + "' couldn't be read because of a "
              "syntax error in the xml file. " + e.msg
          )
  
      root = tree.getroot()
  
      if root is None:
          raise XMLParseError(
              "The xml file '" + xmlfile + "' is empty."
          )
  
      for pagecount, pageNode in enumerate(root):
          a = XMLReader.requireAttr(
              pageNode,
              ["width", "height", "resolution", "originalCoords"],
          )
          page = Page(
              a["width"],
              a["height"],
              a["resolution"],
              a["originalCoords"],
              imgfile,
              xmlfile,
          )
  
          for blockcount, blockNode in enumerate(pageNode):
              # Checks if the blockType is text, ignoring all other types
              type = blockNode.get("blockType")
              if type is not None and type == "Text":
                  # Reads rectangle data and controls if they are empty
                  name = blockNode.get("blockName")
  
                  block = Block(
                      type,
                      name,
                      XMLReader.parseRect(blockNode, required=False),
                  )
  
                  for textNode in blockNode:
                      # Again only text nodes will be considered
  
                      if (
                          textNode.tag
                          == "{http://www.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml}text"
                      ):
                          for parNode in textNode:
                              align = parNode.get("align")
                              startIndent = parNode.get("startIndent")
                              lineSpacing = parNode.get("lineSpacing")
  
                              par = Par(align, startIndent, lineSpacing)
  
                              for linecount, lineNode in enumerate(
                                  parNode
                              ):
                                  baseline = lineNode.get("baseline")
  
                                  line = Line(
                                      baseline,
                                      XMLReader.parseRect(lineNode),
                                  )
  
                                  lang = None
                                  text = ""
                                  maxCount = 0
                                  for formNode in lineNode:
                                      countChars = 0
                                      if (
                                          formNode.text is None
                                          or formNode.text == "\n"
                                          or formNode.text == ""
                                      ):
                                          for charNode in formNode:
                                              text += str(charNode.text)
                                              countChars = (
                                                  countChars + 1
                                              )
                                          if countChars > maxCount:
                                              maxCount = countChars
                                              lang = formNode.get(
                                                  "lang"
                                              )
  
                                      else:
                                          lang = formNode.get("lang")
                                          text = str(formNode.text)
  
                                  format = Format(lang, text)
                                  line.formats.append(format)
                                  par.lines.append(line)
  
                              block.pars.append(par)
  
                  page.blocks.append(block)
  
          yield page
  
file_path: calamari/calamari_ocr/ocr/dataset/datareader/abbyy/xml/reader.py
imports: import os
  from lxml import etree
  from .data import Book, Page, Block, Format, Line, Par, Rect
  from .exceptions import XMLParseError
  from tqdm import tqdm
  import logging
label_desc: Use image node_id 5 for calling the XMLReader obj's underlying member method code with example usage: obj.parseXMLfile(imgfile, xmlfile) without return types