 
 /// EpubParser support class, parsing the OPF package document in the container.
 /// OPF (Open Packaging Format)
-open class OPFParser {
-
-    // Mark: - Public methods.
-
-    public init() {}
+public class OPFParser {
 
     // MARK: - Internal methods.
+
+    internal init() {}
 
     /// Parse the OPF file of the Epub container and return a `Publication`.
     ///

    ///   - publication: The publication whose spine and resources will be built.
    ///   - coverItemId: The id of the cover item in the manifest.
    internal func parseSpineAndResources(from document: AEXMLDocument,
                                         to publication: Publication,
                                         with coverItemId: String?) {
        let manifest = document.root["manifest"]
        // Create a dictionary for all the manifest items keyed by their id
        var manifestLinks = [String: Link]()
        defer {
            // Those links that were not in the spine are the resources,
            // they've already been removed from the manifestLinks dictionary
            publication.resources = [Link](manifestLinks.values)
        }

        parseManifestItems(from: manifest, to: publication, and: &manifestLinks,
                           with: coverItemId)
        // Parse the `<spine>` element children
        guard let spineItems = document.root["spine"]["itemref"].all else {
            return

        ///     Relative path to the package.opf file.
        let rootFilePath = container.metadata.rootFilePath

        // Get the package.opf XML document from the container.
        document = try getXmlDocumentForFile(in: container,
                                             atPath: rootFilePath)
        // Try to get EPUB version from the <package> element.
        // Else set it to default value.
        container.metadata.epubVersion = getEpubVersion(from: document)

        // TODO: Add self to links
        // But we don't know the self URL here
        //publication.links.append(Link(href: "TODO", typeLink: "application/webpub+json", rel: "self"))

        // Parse Metadata from the XML document.
        metadata = parseMetadata(from: document,
                                 with: container.metadata.epubVersion)
        // Get the page progression direction.
        if let dir = document.root["spine"].attributes["page-progression-direction"] {
            metadata.direction = dir
        }
        // Look for the manifest item id of the cover.
        parseSpineAndResources(from: document, to: publication)
        //
        publication.metadata = metadata
        publication.internalData["type"] = "epub"
        publication.internalData["rootfile"] = rootFilePath
        return publication
    }

