public EpubSummaryParser(Stream source)
        {
            _zip = ZipContainer.Unzip(source);
            XDocument xmlDocument = _zip.GetFileStream("META-INF/container.xml").GetXmlDocument();
            XElement root = xmlDocument.Root;
            if (root == null)
                throw new DataException(InvalidEpubMetaInfo);

            XAttribute attribute = root.Attribute("xmlns");
            XNamespace xmlns = (attribute != null) ? XNamespace.Get(attribute.Value) : XNamespace.None;
            XAttribute fullPath = xmlDocument.Descendants(xmlns + "rootfile").First().Attribute("full-path");
            if (fullPath == null)
                throw new DataException(InvalidEpubMetaInfo);

            string path = fullPath.Value;
            _opfPath = path;
            _opf = _zip.GetFileStream(path).GetXmlDocument();
            _opfRoot = _opf.Root;
            if (_opfRoot == null)
                throw new DataException(InvalidEpubMetaInfo);

            _oebps = GetPath(path);
            _opfns = XNamespace.Get("http://www.idpf.org/2007/opf");
            _opfdc = XNamespace.Get("http://purl.org/dc/elements/1.1/");

            _coverHelper = new EpubCoverHelper(_zip, _opfns, _opfRoot, _oebps);
        }
 public EpubCoverHelper(ZipContainer zip, XNamespace opfns, XElement opfRoot, string oebps)
 {
     _zip = zip;
     _opfns = opfns;
     _opfRoot = opfRoot;
     _oebps = oebps;
 }
示例#3
0
        public EpubTokenParser(XDocument opf, EpubPath opfPath, ZipContainer zip, CSS css, Dictionary<string, int> anchors)
        {
            _opf = opf;
            _opfPath = opfPath;
            _zip = zip;
            _css = css;
            _anchors = anchors;
            _opfns = XNamespace.Get("http://www.idpf.org/2007/opf");

            _opfRoot = _opf.Root;
            if (_opfRoot == null)
                throw new DataException("Invalid epub meta info.");
        }