Last active
August 21, 2019 03:29
-
-
Save stonezhl/0749ae51bd25da1a693656b28bb4e9fd to your computer and use it in GitHub Desktop.
OPFSpine Struct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Kanna | |
struct OPFSpine { | |
private(set) var idrefs = [String]() | |
init?(package: XMLElement) { | |
guard let spine = package.at_xpath("opf:spine", namespaces: XPath.opf.namespace) else { return nil } | |
idrefs = spine.xpath("opf:itemref[@idref]/@idref", namespaces: opfNamespace) | |
.map { $0.text } | |
.compactMap { $0 } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment