 
 /// 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`.
     ///

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

        // Get `Data` from the Container/OPFFile
        guard let opfData = try? container.data(relativePath: rootFilePath) else {
            throw EpubParserError.missingFile(path: rootFilePath)
        }
        // Create an XML document from the OPF Data
        do {
            document = try AEXMLDocument(xml: opfData)
        } catch {
            throw EpubParserError.xmlParse(underlyingError: error)
        }

        // Try to get EPUB version from the <package> element. Else set to
        // default value.
        if let version = document.root.attributes["version"],
            let versionNumber = Double(version) {
            container.metadata.epubVersion = versionNumber
        } else {
            container.metadata.epubVersion = EpubConstant.defaultEpubVersion
        }
        
        publication.internalData["type"] = "epub"
        publication.internalData["rootfile"] = rootFilePath
        // Add self to links
        // MARK: we don't know the self URL here
        //publication!.links.append(Link(href: "TODO", typeLink: "application/webpub+json", rel: "self"))
        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
        }
        publication.metadata = metadata

        // Look for the manifest item id of the cover
        var coverId: String?
        let metadataElement = document.root["metadata"]

        if let coverMetas = metadataElement["meta"].all(withAttributes: ["name" : "cover"]) {
            coverId = coverMetas.first?.string
        }
        parseSpineAndResources(from: document, to: publication, with: coverId)
        return publication
    }


        link.properties.append(contentsOf: remainingProperties)
        // TODO: rendition properties
    }

    // MARK: - Private methods.

    /// Takes a Container and the path to one of it's ressource and returns an
    /// XML document.
    ///
    /// - Parameters:
    ///   - container: The Container containing the XML file.
    ///   - path: The path to the XML file.
    /// - Returns: The XML document Object generated.
    /// - Throws: EpubParserError.missingFile(),
    ///           EpubParserError.xmlParse().
    private func getXmlDocumentForFile(in container: Container,
                                       atPath path: String
        ) throws -> AEXMLDocument {
        // The 'to be built' XML Document
        var document: AEXMLDocument

        // Get `Data` from the Container/OPFFile
        guard let data = try? container.data(relativePath: path) else {
            throw EpubParserError.missingFile(path: path)
        }
        // Transforms `Data` into an AEXML Document object
        do {
            document = try AEXMLDocument(xml: data)
        } catch {
            throw EpubParserError.xmlParse(underlyingError: error)
        }
        return document
    }

    /// Retrieve the EPUB version from the package.opf XML document.
    private func getEpubVersion(from document: AEXMLDocument) -> Double {
        var version: Double

        if let version = document.root.attributes["version"],
            let versionNumber = Double(version) {
            version = versionNumber
        } else {
            version = EpubConstant.defaultEpubVersion
        }
        return version
    }
    
}
