protected virtual void AddPagePropertiesToAudioNode(TreeNode audioWrapperNode, XmlNode pageTargetNode) { TextMedia textMedia = audioWrapperNode.Presentation.MediaFactory.CreateTextMedia(); textMedia.Text = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(pageTargetNode, true, "text", pageTargetNode.NamespaceURI).InnerText; ChannelsProperty cProp = audioWrapperNode.Presentation.PropertyFactory.CreateChannelsProperty(); cProp.SetMedia(audioWrapperNode.Presentation.ChannelsManager.GetOrCreateTextChannel(), textMedia); audioWrapperNode.AddProperty(cProp); System.Xml.XmlAttributeCollection pageAttributes = pageTargetNode.Attributes; if (pageAttributes != null) { XmlProperty xmlProp = audioWrapperNode.GetXmlProperty(); xmlProp.SetQName("pagenum", ""); string nsUri = audioWrapperNode.GetXmlNamespaceUri(); foreach (System.Xml.XmlAttribute attr in pageAttributes) { string uri = ""; if (!string.IsNullOrEmpty(attr.NamespaceURI)) { if (attr.NamespaceURI != nsUri) { uri = attr.NamespaceURI; } } xmlProp.SetAttribute(attr.Name, uri, attr.Value); } } }
protected virtual TreeNode CheckAndAssignForHeadingAudio(TreeNode navPointTreeNode, TreeNode phraseTreeNode, XmlNode audioXmlNode) { XmlNode navLabelXmlNode = m_NavPointNode_NavLabelMap[navPointTreeNode]; XmlNode headingAudio = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(navLabelXmlNode, true, "audio", navLabelXmlNode.NamespaceURI); XmlNode textNode = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(navLabelXmlNode, true, "text", navLabelXmlNode.NamespaceURI); double headingClipBegin = Math.Abs((new urakawa.media.timing.Time(headingAudio.Attributes.GetNamedItem("clipBegin").Value)).AsMilliseconds); double headingClipEnd = Math.Abs((new urakawa.media.timing.Time(headingAudio.Attributes.GetNamedItem("clipEnd").Value)).AsMilliseconds); double audioClipBegin = Math.Abs((new urakawa.media.timing.Time(audioXmlNode.Attributes.GetNamedItem("clipBegin").Value)).AsMilliseconds); double audioClipEnd = Math.Abs((new urakawa.media.timing.Time(audioXmlNode.Attributes.GetNamedItem("clipEnd").Value)).AsMilliseconds); if (headingAudio.Attributes.GetNamedItem("src").Value == audioXmlNode.Attributes.GetNamedItem("src").Value && Math.Abs(headingClipBegin - audioClipBegin) <= 1 && Math.Abs(headingClipEnd - audioClipEnd) <= 1) { TextMedia textMedia = navPointTreeNode.Presentation.MediaFactory.CreateTextMedia(); textMedia.Text = textNode.InnerText; ChannelsProperty cProp = navPointTreeNode.Presentation.PropertyFactory.CreateChannelsProperty(); cProp.SetMedia(navPointTreeNode.Presentation.ChannelsManager.GetOrCreateTextChannel(), textMedia); //TreeNode txtWrapperNode = parentNode.Presentation.TreeNodeFactory.Create(); phraseTreeNode.AddProperty(cProp); //treeNode.AppendChild(txtWrapperNode); XmlProperty TextNodeXmlProp = navPointTreeNode.Presentation.PropertyFactory.CreateXmlProperty(); phraseTreeNode.AddProperty(TextNodeXmlProp); TextNodeXmlProp.SetQName("hd", ""); } return(phraseTreeNode); }
public virtual void ParseNCXDocument(XmlDocument ncxDocument) { m_SmilRefToNavPointTreeNodeMap = new Dictionary <string, TreeNode>(); m_NavPointNode_NavLabelMap = new Dictionary <TreeNode, XmlNode>(); //string ncxPath = Directory.GetFiles(Directory.GetParent(m_Book_FilePath).FullName, "*.ncx")[0]; //ncxDocument = xuk.OpenXukAction.ParseXmlDocument(ncxPath, false); XmlNode navMap = ncxDocument.GetElementsByTagName("navMap")[0]; Presentation presentation = m_Project.Presentations.Get(0); XmlProperty xmlProp = presentation.PropertyFactory.CreateXmlProperty(); xmlProp.SetQName("book", navMap.NamespaceURI == null ? "" : navMap.NamespaceURI); presentation.PropertyFactory.DefaultXmlNamespaceUri = navMap.NamespaceURI; TreeNode treeNode = null; if (presentation.RootNode == null) { treeNode = presentation.TreeNodeFactory.Create(); presentation.RootNode = treeNode; } else { treeNode = presentation.RootNode; } treeNode.AddProperty(xmlProp); m_DocTitleXmlNode = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(ncxDocument.DocumentElement, true, "docTitle", ncxDocument.DocumentElement.NamespaceURI); m_IsDocTitleCreated = false; ParseNCXNodes(presentation, navMap, treeNode); CollectPagesFromPageList(navMap); }
protected virtual TreeNode AddAnchorNode(TreeNode navPointTreeNode, XmlNode textPeerNode, string fullSmilPath) { TreeNode anchorNode = navPointTreeNode.Presentation.TreeNodeFactory.Create(); navPointTreeNode.AppendChild(anchorNode); XmlNode xmlNodeAttr = textPeerNode.Attributes.GetNamedItem("href"); string strReferedID = xmlNodeAttr.Value; XmlNode seqParent = textPeerNode.ParentNode; while (seqParent != null) { if (seqParent.LocalName == "seq" && seqParent.Attributes.GetNamedItem("customTest") != null) { break; } seqParent = seqParent.ParentNode; } string strClass = seqParent.Attributes.GetNamedItem("class").Value; if (strClass != null) { XmlProperty prop = anchorNode.GetOrCreateXmlProperty(); prop.SetQName(strClass, ""); prop.SetAttribute(xmlNodeAttr.Name, "", strReferedID); } return(anchorNode); }
protected XmlProperty ObiNodeGetOrCreateXmlProperty() { XmlProperty xmlProp = this.GetProperty <urakawa.property.xml.XmlProperty>(); if (xmlProp == null) { xmlProp = Presentation.PropertyFactory.CreateXmlProperty(); this.AddProperty(xmlProp); xmlProp.SetQName(XmlPropertyString, GetXukNamespace()); } return(xmlProp); }
protected virtual TreeNode CreateTreeNodeForNavPoint(TreeNode parentNode, XmlNode navPoint) { TreeNode treeNode = parentNode.Presentation.TreeNodeFactory.Create(); if (navPoint.LocalName == "navPoint") { parentNode.AppendChild(treeNode); XmlProperty xmlProp = parentNode.Presentation.PropertyFactory.CreateXmlProperty(); treeNode.AddProperty(xmlProp); //XmlNode textNode = XmlDocumentHelper.GetFirstChildElementWithName(navPoint, true, "text", navPoint.NamespaceURI); //+":" + textNode.InnerText; xmlProp.SetQName("level", ""); } else if (navPoint.LocalName == "docTitle") { Presentation pres = m_Project.Presentations.Get(0); pres.RootNode.Insert(treeNode, 0); XmlProperty xmlProp = pres.PropertyFactory.CreateXmlProperty(); treeNode.AddProperty(xmlProp); //XmlNode textNode = XmlDocumentHelper.GetFirstChildElementWithName(navPoint, true, "text", navPoint.NamespaceURI); xmlProp.SetQName("doctitle", ""); } // create urakawa tree node //TextMedia textMedia = parentNode.Presentation.MediaFactory.CreateTextMedia(); //textMedia.Text = textNode.InnerText; //ChannelsProperty cProp = parentNode.Presentation.PropertyFactory.CreateChannelsProperty(); //cProp.SetMedia(m_textChannel, textMedia); //TreeNode txtWrapperNode = parentNode.Presentation.TreeNodeFactory.Create(); //txtWrapperNode.AddProperty(cProp); //treeNode.AppendChild(txtWrapperNode); //XmlProperty TextNodeXmlProp = parentNode.Presentation.PropertyFactory.CreateXmlProperty(); //txtWrapperNode.AddProperty(TextNodeXmlProp); //TextNodeXmlProp.LocalName = "hd"; return(treeNode); }
private void parseSmilForNCX(string fullSmilPath) { //foreach (string s in m_SmilRefToNavPointTreeNodeMap.Keys) System.Windows.Forms.MessageBox.Show(s + " : " + m_SmilRefToNavPointTreeNodeMap[s].GetXmlElementLocalName() ); if (RequestCancellation) { return; } XmlDocument smilXmlDoc = XmlReaderWriterHelper.ParseXmlDocument(fullSmilPath, false, false); if (RequestCancellation) { return; } m_SmilXmlNodeToTreeNodeMap = new Dictionary <XmlNode, TreeNode>(); //we skip SMIL metadata parsing (we get publication metadata only from OPF and DTBOOK/XHTMLs) //parseMetadata(smilXmlDoc); //XmlNodeList allTextNodes = smilXmlDoc.GetElementsByTagName("text"); //if (allTextNodes.Count == 0) //{ // return; //} //reportProgress(-1, "Parsing SMIL: [" + Path.GetFileName(fullSmilPath) + "]"); TreeNode navPointTreeNode = null; XmlNamespaceManager firstDocNSManager = new XmlNamespaceManager(smilXmlDoc.NameTable); firstDocNSManager.AddNamespace("firstNS", smilXmlDoc.DocumentElement.NamespaceURI); bool isHeading = false; bool isPageInProcess = false; TreeNode audioWrapperNode = null; XmlNodeList smilNodeList = smilXmlDoc.DocumentElement.SelectNodes(".//firstNS:seq | .//firstNS:par", firstDocNSManager); //foreach (XmlNode parNode in XmlDocumentHelper.GetChildrenElementsWithName(smilXmlDoc, true, "par", null, false)) foreach (XmlNode parNode in smilNodeList) { XmlAttributeCollection parNodeAttrs = parNode.Attributes; if (parNodeAttrs == null || parNodeAttrs.Count == 0) { continue; } //XmlNode textNodeAttrSrc = parNodeAttrs.GetNamedItem("src"); XmlNode parNodeID = parNodeAttrs.GetNamedItem("id"); if (parNodeID == null || String.IsNullOrEmpty(parNodeID.Value)) { continue; } string ncxContentSRC = Path.GetFileName(fullSmilPath) + "#" + parNodeID.Value; TreeNode obj; m_SmilRefToNavPointTreeNodeMap.TryGetValue(ncxContentSRC, out obj); // for now we are assuming the first phrase as heading phrase. this need refinement such that phrase anywhere in section can be imported as heading) if (obj != null) //m_SmilRefToNavPointTreeNodeMap.ContainsKey(ncxContentSRC)) { m_IsDocTitleCreated = true; navPointTreeNode = obj; // m_SmilRefToNavPointTreeNodeMap[ncxContentSRC]; //System.Windows.Forms.MessageBox.Show(ncxContentSRC + " section:" + navPointTreeNode.GetXmlElementLocalName() + " : " + Path.GetFileName( fullSmilPath ) ); //: audioWrapperNode = CreateTreeNodeForAudioNode(navPointTreeNode, true); //isHeading = true; } // handle doctitle if audio exists before first heading by adding doctitle node as first treenode if (navPointTreeNode == null && !m_IsDocTitleCreated && (XmlDocumentHelper.GetFirstChildElementOrSelfWithName(parNode, false, "audio", null) != null || XmlDocumentHelper.GetFirstChildElementOrSelfWithName(parNode, false, "text", null) != null)) { m_IsDocTitleCreated = true; navPointTreeNode = CreateTreeNodeForNavPoint(m_Project.Presentations.Get(0).RootNode, m_DocTitleXmlNode); m_NavPointNode_NavLabelMap.Add(navPointTreeNode, m_DocTitleXmlNode); } //else if (m_PageReferencesMapDictionaryForNCX.ContainsKey(ncxContentSRC) if (m_PageReferencesMapDictionaryForNCX.ContainsKey(ncxContentSRC) || (parNode.Attributes.GetNamedItem("customTest") != null && parNode.Attributes.GetNamedItem("customTest").Value == "pagenum")) { isPageInProcess = true; if (navPointTreeNode == null) { continue; } //:audioWrapperNode = CreateTreeNodeForAudioNode(navPointTreeNode, false); } if (navPointTreeNode == null) { continue; } //System.Windows.Forms.MessageBox.Show(parNode.LocalName); ManagedAudioMedia textTreeNodeAudio = navPointTreeNode.GetManagedAudioMedia(); if (textTreeNodeAudio != null) { //Ignore. continue; } XmlNodeList textPeers = parNode.ChildNodes; foreach (XmlNode textPeerNode in textPeers) //foreach (XmlNode textPeerNode in XmlDocumentHelper.GetChildrenElementsWithName(parNode, true, "audio", null, false)) { if (RequestCancellation) { return; } //if (XmlDocumentHelper.GetFirstChildElementWithName(parNode, false, "audio", null) == null) continue; if (textPeerNode.NodeType != XmlNodeType.Element) { continue; } if (textPeerNode.LocalName == "audio") { audioWrapperNode = CreateTreeNodeForAudioNode(navPointTreeNode, isHeading, textPeerNode, fullSmilPath); CheckAndAssignForHeadingAudio(navPointTreeNode, audioWrapperNode, textPeerNode); XmlProperty xmlProp = navPointTreeNode.Presentation.PropertyFactory.CreateXmlProperty(); audioWrapperNode.AddProperty(xmlProp); // +":" + navPointTreeNode.GetTextFlattened(false); xmlProp.SetQName("phrase", ""); string pageRefInSmil = Path.GetFileName(fullSmilPath) + "#" + parNode.Attributes.GetNamedItem("id").Value; XmlNode xNode; m_PageReferencesMapDictionaryForNCX.TryGetValue(pageRefInSmil, out xNode); if (xNode != null && //m_PageReferencesMapDictionaryForNCX.ContainsKey(pageRefInSmil) isPageInProcess) { isPageInProcess = false; XmlNode pageTargetNode = xNode; //m_PageReferencesMapDictionaryForNCX[pageRefInSmil]; AddPagePropertiesToAudioNode(audioWrapperNode, pageTargetNode); } isHeading = false; addAudio(audioWrapperNode, textPeerNode, false, fullSmilPath); break; } else if (textPeerNode.LocalName == "a") { XmlNodeList aChildren = textPeerNode.ChildNodes; foreach (XmlNode aChild in aChildren) { if (aChild.LocalName == "audio") { //addAudio(audioWrapperNode, aChild, false, fullSmilPath); audioWrapperNode = CreateTreeNodeForAudioNode(navPointTreeNode, false, aChild, fullSmilPath); addAudio(audioWrapperNode, aChild, false, fullSmilPath); break; } else { AddAnchorNode(navPointTreeNode, textPeerNode, fullSmilPath); break; } } } else if (textPeerNode.LocalName == "seq" || textPeerNode.LocalName == "par") { if (audioWrapperNode != null) { m_SmilXmlNodeToTreeNodeMap.Add(textPeerNode, audioWrapperNode); } /* * XmlNodeList seqChildren = textPeerNode.ChildNodes; * foreach (XmlNode seqChild in seqChildren) * //1{ * if (seqChild.LocalName == "audio") * {//2 * addAudio(audioWrapperNode, seqChild, true, fullSmilPath); * }//-2 * }//-1 * * SequenceMedia seqManAudioMedia = audioWrapperNode.GetManagedAudioSequenceMedia(); * if (seqManAudioMedia == null) * {//1 * //Debug.Fail("This should never happen !"); * break; * }//-1 * * ManagedAudioMedia managedAudioMedia = audioWrapperNode.Presentation.MediaFactory.CreateManagedAudioMedia(); * AudioMediaData mediaData = audioWrapperNode.Presentation.MediaDataFactory.CreateAudioMediaData(); * managedAudioMedia.AudioMediaData = mediaData; * * foreach (Media seqChild in seqManAudioMedia.ChildMedias.ContentsAs_YieldEnumerable) * {//1 * ManagedAudioMedia seqManMedia = (ManagedAudioMedia)seqChild; * mediaData.MergeWith(seqManMedia.AudioMediaData); * }//-1 * * ChannelsProperty chProp = audioWrapperNode.GetChannelsProperty(); * chProp.SetMedia(m_audioChannel, null); * chProp.SetMedia(m_audioChannel, managedAudioMedia); */ break; } } } }
protected override void parseContentDocument(string filePath, Project project, XmlNode xmlNode, TreeNode parentTreeNode, string dtdUniqueResourceId, DocumentMarkupType docMarkupType) { if (RequestCancellation) { return; } XmlNodeType xmlType = xmlNode.NodeType; switch (xmlType) { case XmlNodeType.Attribute: { System.Diagnostics.Debug.Fail("Calling this method with an XmlAttribute should never happen !!"); break; } case XmlNodeType.Document: { XmlNode bodyElement = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(xmlNode, true, "body", null); if (bodyElement == null) { bodyElement = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(xmlNode, true, "book", null); } if (bodyElement != null) { Presentation presentation = m_Project.Presentations.Get(0); presentation.PropertyFactory.DefaultXmlNamespaceUri = bodyElement.NamespaceURI; parseContentDocument(filePath, project, bodyElement, parentTreeNode, null, docMarkupType); } //parseContentDocument(((XmlDocument)xmlNode).DocumentElement, parentTreeNode); break; } case XmlNodeType.Element: { Presentation presentation = m_Project.Presentations.Get(0); TreeNode treeNode = null; if (parentTreeNode == null) { parentTreeNode = GetFirstTreeNodeForXmlDocument(presentation, xmlNode); //parentTreeNode = presentation.RootNode; } if (parentTreeNode != null) { treeNode = CreateAndAddTreeNodeForContentDocument(parentTreeNode, xmlNode, Path.GetFileName(filePath)); if (treeNode != null && treeNode is EmptyNode && ((EmptyNode)treeNode).PageNumber != null) { string strfRefID = Path.GetFileName(filePath) + "#" + xmlNode.Attributes.GetNamedItem("id").Value; m_XmlIdToPageNodeMap.Add(strfRefID, (EmptyNode)treeNode); } //parentTreeNode.AppendChild(treeNode); } if (xmlNode.ParentNode != null && xmlNode.ParentNode.NodeType == XmlNodeType.Document) { presentation.PropertyFactory.DefaultXmlNamespaceUri = xmlNode.NamespaceURI; } XmlProperty xmlProp = null; if (treeNode != null) { xmlProp = presentation.PropertyFactory.CreateXmlProperty(); treeNode.AddProperty(xmlProp); // we get rid of element name prefixes, we use namespace URIs instead. // check inherited NS URI string nsUri = treeNode.Parent != null? treeNode.Parent.GetXmlNamespaceUri() : xmlNode.NamespaceURI; //presentation.PropertyFactory.DefaultXmlNamespaceUri if (xmlNode.NamespaceURI != nsUri) { nsUri = xmlNode.NamespaceURI; xmlProp.SetQName(xmlNode.LocalName, nsUri == null ? "" : nsUri); } else { xmlProp.SetQName(xmlNode.LocalName, ""); } //string nsUri = treeNode.GetXmlNamespaceUri(); // if xmlNode.NamespaceURI != nsUri // => xmlProp.GetNamespaceUri() == xmlNode.NamespaceURI } if (parentTreeNode is SectionNode && (xmlNode.LocalName == "h1" || xmlNode.LocalName == "h2" || xmlNode.LocalName == "h3" || xmlNode.LocalName == "h4" || xmlNode.LocalName == "h5" || xmlNode.LocalName == "h6" || xmlNode.LocalName == "HD")) { ((SectionNode)parentTreeNode).Label = xmlNode.InnerText.Replace("\n", "").Replace("\r", "").Replace("\t", ""); Console.WriteLine("DTBook: " + ((SectionNode)parentTreeNode).Label); if (xmlNode.Attributes.GetNamedItem("id") != null) { string strfRefID = Path.GetFileName(filePath) + "#" + xmlNode.Attributes.GetNamedItem("id").Value; if (!m_XmlIdToSectionNodeMap.ContainsKey(strfRefID)) { m_XmlIdToSectionNodeMap.Add(strfRefID, (SectionNode)parentTreeNode); } } } if (treeNode != null && treeNode is SectionNode && xmlNode.LocalName == "doctitle") { ((SectionNode)treeNode).Label = xmlNode.InnerText.Replace("\n", "").Replace("\r", "").Replace("\t", "");; } if (RequestCancellation) { return; } foreach (XmlNode childXmlNode in xmlNode.ChildNodes) { parseContentDocument(filePath, project, childXmlNode, treeNode != null && treeNode is SectionNode ? treeNode : parentTreeNode, null, docMarkupType); } break; } case XmlNodeType.Whitespace: case XmlNodeType.CDATA: case XmlNodeType.SignificantWhitespace: case XmlNodeType.Text: { /* * Presentation presentation = Project.Presentations.Get(0); * * if (xmlType == XmlNodeType.Whitespace) * { * bool onlySpaces = true; * for (int i = 0; i < xmlNode.Value.Length; i++) * { * if (xmlNode.Value[i] != ' ') * { * onlySpaces = false; * break; * } * } * if (!onlySpaces) * { * break; * } * //else * //{ * // int l = xmlNode.Value.Length; * //} * } #if DEBUG * if (xmlType == XmlNodeType.CDATA) * { * Debugger.Break(); * } * * if (xmlType == XmlNodeType.SignificantWhitespace) * { * Debugger.Break(); * } #endif * //string text = xmlNode.Value.Trim(); * string text = System.Text.RegularExpressions.Regex.Replace(xmlNode.Value, @"\s+", " "); * * Debug.Assert(!string.IsNullOrEmpty(text)); * #if DEBUG * if (text.Length != xmlNode.Value.Length) * { * int debug = 1; * //Debugger.Break(); * } * * if (string.IsNullOrEmpty(text)) * { * Debugger.Break(); * } * if (xmlType != XmlNodeType.Whitespace && text == " ") * { * int debug = 1; * //Debugger.Break(); * } #endif * if (string.IsNullOrEmpty(text)) * { * break; * } * urakawa.media.TextMedia textMedia = presentation.MediaFactory.CreateTextMedia(); * textMedia.Text = text; * * urakawa.property.channel.ChannelsProperty cProp = presentation.PropertyFactory.CreateChannelsProperty(); * cProp.SetMedia(m_textChannel, textMedia); * * * int counter = 0; * foreach (XmlNode childXmlNode in xmlNode.ParentNode.ChildNodes) * { * XmlNodeType childXmlType = childXmlNode.NodeType; * if (childXmlType == XmlNodeType.Text || childXmlType == XmlNodeType.Element || childXmlType == XmlNodeType.Whitespace || childXmlType == XmlNodeType.SignificantWhitespace || childXmlType == XmlNodeType.CDATA) || { || counter++; || } ||} ||if (counter == 1) ||{ || parentTreeNode.AddProperty(cProp); ||} ||else ||{ || TreeNode txtWrapperNode = presentation.TreeNodeFactory.Create(); || txtWrapperNode.AddProperty(cProp); || parentTreeNode.AppendChild(txtWrapperNode); ||} */ break; } default: { return; } } }
private void parseHeadLinks(string rootFilePath, Project project, XmlDocument contentDoc) { XmlNode headXmlNode = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(contentDoc.DocumentElement, true, "head", null); if (headXmlNode == null) { return; } Presentation presentation = project.Presentations.Get(0); List <string> externalFileRelativePaths = new List <string>(); foreach (ExternalFiles.ExternalFileData extData in presentation.ExternalFilesDataManager.ManagedObjects.ContentsAs_Enumerable) { if (!string.IsNullOrEmpty(extData.OriginalRelativePath)) { string fullPath = Path.Combine(Path.GetDirectoryName(rootFilePath), extData.OriginalRelativePath); string relPath = FileDataProvider.NormaliseFullFilePath(fullPath).Replace('/', '\\'); if (!externalFileRelativePaths.Contains(relPath)) { externalFileRelativePaths.Add(relPath); } } } List <XmlNode> externalFilesLinks = new List <XmlNode>(); externalFilesLinks.AddRange(XmlDocumentHelper.GetChildrenElementsOrSelfWithName(headXmlNode, true, "link", headXmlNode.NamespaceURI, false)); externalFilesLinks.AddRange(XmlDocumentHelper.GetChildrenElementsOrSelfWithName(headXmlNode, true, "script", headXmlNode.NamespaceURI, false)); externalFilesLinks.AddRange(XmlDocumentHelper.GetChildrenElementsOrSelfWithName(headXmlNode, true, "style", headXmlNode.NamespaceURI, false)); externalFilesLinks.AddRange(XmlDocumentHelper.GetChildrenElementsOrSelfWithName(headXmlNode, true, "title", headXmlNode.NamespaceURI, false)); foreach (XmlNode linkNode in externalFilesLinks) { TreeNode treeNode = presentation.TreeNodeFactory.Create(); presentation.HeadNode.AppendChild(treeNode); XmlProperty xmlProp = presentation.PropertyFactory.CreateXmlProperty(); treeNode.AddProperty(xmlProp); xmlProp.SetQName(linkNode.LocalName, headXmlNode.NamespaceURI == linkNode.NamespaceURI ? "" : linkNode.NamespaceURI); //Console.WriteLine("XmlProperty: " + xmlProp.LocalName); foreach (System.Xml.XmlAttribute xAttr in linkNode.Attributes) { if ( //xAttr.LocalName.Equals(XmlReaderWriterHelper.NS_PREFIX_XMLNS, StringComparison.OrdinalIgnoreCase) //|| xAttr.LocalName.Equals("xsi", StringComparison.OrdinalIgnoreCase) xAttr.NamespaceURI.Equals(XmlReaderWriterHelper.NS_URL_XMLNS, StringComparison.OrdinalIgnoreCase) || xAttr.LocalName.Equals("space", StringComparison.OrdinalIgnoreCase) && xAttr.NamespaceURI.Equals(XmlReaderWriterHelper.NS_URL_XML, StringComparison.OrdinalIgnoreCase) ) { continue; } xmlProp.SetAttribute(xAttr.Name, linkNode.NamespaceURI == xAttr.NamespaceURI ? "" : xAttr.NamespaceURI, xAttr.Value); if ((xAttr.Name.Equals("href", StringComparison.OrdinalIgnoreCase) || xAttr.Name.Equals("src", StringComparison.OrdinalIgnoreCase)) && !string.IsNullOrEmpty(xAttr.Value) && !FileDataProvider.isHTTPFile(xAttr.Value)) { string urlDecoded = FileDataProvider.UriDecode(xAttr.Value); string fullPath = Path.Combine(Path.GetDirectoryName(rootFilePath), urlDecoded); string pathFromAttr = FileDataProvider.NormaliseFullFilePath(fullPath).Replace('/', '\\'); if (!externalFileRelativePaths.Contains(pathFromAttr)) { if (File.Exists(pathFromAttr)) { ExternalFiles.ExternalFileData efd = presentation.ExternalFilesDataFactory.Create <ExternalFiles.GenericExternalFileData>(); try { efd.InitializeWithData(pathFromAttr, urlDecoded, true, null); externalFileRelativePaths.Add(pathFromAttr); addOPF_GlobalAssetPath(pathFromAttr); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); #if DEBUG Debugger.Break(); #endif } } #if DEBUG else { Debugger.Break(); } #endif } } } string innerText = linkNode.InnerText; // includes CDATA sections! (merges "//" javascript comment markers too) if (!string.IsNullOrEmpty(innerText)) { urakawa.media.TextMedia textMedia = presentation.MediaFactory.CreateTextMedia(); textMedia.Text = innerText; ChannelsProperty cProp = presentation.PropertyFactory.CreateChannelsProperty(); cProp.SetMedia(presentation.ChannelsManager.GetOrCreateTextChannel(), textMedia); treeNode.AddProperty(cProp); //Console.WriteLine("Link inner text: " + textMedia.Text); } } }