private static EpubSpine ReadSpine(XElement spineNode, EpubVersion epubVersion)
        {
            EpubSpine result = new EpubSpine();

            foreach (XAttribute spineNodeAttribute in spineNode.Attributes())
            {
                string attributeValue = spineNodeAttribute.Value;
                switch (spineNodeAttribute.GetLowerCaseLocalName())
                {
                case "id":
                    result.Id = attributeValue;
                    break;

                case "page-progression-direction":
                    result.PageProgressionDirection = PageProgressionDirectionParser.Parse(attributeValue);
                    break;

                case "toc":
                    result.Toc = attributeValue;
                    break;
                }
            }
            if (epubVersion == EpubVersion.EPUB_2 && String.IsNullOrWhiteSpace(result.Toc))
            {
                throw new Exception("Incorrect EPUB spine: TOC is missing");
            }
            foreach (XElement spineItemNode in spineNode.Elements())
            {
                if (spineItemNode.CompareNameTo("itemref"))
                {
                    EpubSpineItemRef spineItemRef = new EpubSpineItemRef();
                    foreach (XAttribute spineItemNodeAttribute in spineItemNode.Attributes())
                    {
                        string attributeValue = spineItemNodeAttribute.Value;
                        switch (spineItemNodeAttribute.GetLowerCaseLocalName())
                        {
                        case "id":
                            spineItemRef.Id = attributeValue;
                            break;

                        case "idref":
                            spineItemRef.IdRef = attributeValue;
                            break;

                        case "properties":
                            spineItemRef.Properties = SpinePropertyParser.ParsePropertyList(attributeValue);
                            break;
                        }
                    }
                    if (String.IsNullOrWhiteSpace(spineItemRef.IdRef))
                    {
                        throw new Exception("Incorrect EPUB spine: item ID ref is missing");
                    }
                    XAttribute linearAttribute = spineItemNode.Attribute("linear");
                    spineItemRef.IsLinear = linearAttribute == null || !linearAttribute.CompareValueTo("no");
                    result.Add(spineItemRef);
                }
            }
            return(result);
        }