GetAttribute() public method

public GetAttribute ( [ attributeName ) : string
attributeName [
return string
コード例 #1
0
ファイル: SvgPathElement.cs プロジェクト: lallous/SvgForXaml
		internal SvgPathElement(INode parent, XmlElement element)
			: base(parent, element.GetAttribute("id"))
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			this.Data = element.GetAttribute("d");
			this.Segments = SvgPathSegmentParser.Parse(this.Data);
		}
コード例 #2
0
		public SvgStylableHelper(ISvgStylable parent, XmlElement element)
		{
			this.ClassName = element.GetAttribute("class");
			this.Style = new CssStyleDeclaration(parent, element.GetAttribute("style"));

			foreach (var pn in PRESENTATION_ATTRIBUTE_NAMES)
			{
				var value = element.GetAttribute(pn);
				if (!string.IsNullOrWhiteSpace(value)) this.Style.SetProperty(pn, value, string.Empty, true);
			}
		}
コード例 #3
0
ファイル: SvgSvgElement.cs プロジェクト: lallous/SvgForXaml
		internal SvgSvgElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);

			this.ViewPort = SvgRect.Parse(element.GetAttribute("viewBox"));
		}
コード例 #4
0
		protected internal SvgGradientElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			var gradientUnits = SvgUnitTypeHelper.Parse(element.GetAttribute("gradientUnits"));
			if (gradientUnits == SvgUnitType.Unknown) gradientUnits = SvgUnitType.ObjectBoundingBox;
			this.GradientUnits = gradientUnits;

			this.GradientTransform = SvgTransformParser.Parse(element.GetAttribute("gradientTransform"));

			var spreadMethod = SvgSpreadMethodTypeHelper.Parse(element.GetAttribute("spreadMethod"));
			if (spreadMethod == SvgSpreadMethodType.Unknown) spreadMethod = SvgSpreadMethodType.Pad;
			this.SpreadMethod = spreadMethod;
		}
コード例 #5
0
ファイル: SvgUseElement.cs プロジェクト: lallous/SvgForXaml
		internal SvgUseElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			var nan = new SvgLength(SvgLength.SvgLengthType.Unknown, float.NaN);
			this.X = element.ParseCoordinate("x", nan);
			this.Y = element.ParseCoordinate("y", nan);
			this.Width = element.ParseLength("width", nan);
			this.Height = element.ParseLength("height", nan);
			this.Href = element.GetAttribute("xlink:href").Substring(1);
			
			var child = (SvgElement)this.OwnerDocument.GetElementById(this.Href).CloneNode(true);
			if (child.GetType() == typeof(SvgSymbolElement))
			{
				throw new NotImplementedException();
			}
			else if (child.GetType() == typeof(SvgRectElement))
			{
				var casted = (SvgRectElement)child;
				if (this.Width.UnitType != SvgLength.SvgLengthType.Unknown) casted.Width = this.Width;
				if (this.Height.UnitType != SvgLength.SvgLengthType.Unknown) casted.Height = this.Height;
			}
			this.InstanceRoot = child;

			if (this.X.UnitType != SvgLength.SvgLengthType.Unknown && this.Y.UnitType != SvgLength.SvgLengthType.Unknown)
			{
				this.Transform.Add(SvgTransform.CreateTranslate(
					this.X.UnitType != SvgLength.SvgLengthType.Unknown ? this.X.ValueAsPixel : 0.0F,
					this.Y.UnitType != SvgLength.SvgLengthType.Unknown ? this.Y.ValueAsPixel : 0.0F));
			}
		}
コード例 #6
0
		internal SvgPolygonElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			this.Points = new SvgPointCollection(element.GetAttribute("points"));
		}
コード例 #7
0
		internal SvgClipPathElement(INode parent, XmlElement element)
			: base(parent, element)
		{
			this._stylableHelper = new SvgStylableHelper(this, element);
			this._transformableHelper = new SvgTransformableHelper(element);

			var clipPathUnits = SvgUnitTypeHelper.Parse(element.GetAttribute("clipPathUnits"));
			if (clipPathUnits == SvgUnitType.Unknown) clipPathUnits = SvgUnitType.UserSpaceOnUse;
			this.ClipPathUnits = clipPathUnits;
		}
コード例 #8
0
ファイル: SvgElement.cs プロジェクト: lallous/SvgForXaml
		protected internal SvgElement(INode parent, XmlElement element)
		{
			this.ParentNode = parent;
			this.Id = element.GetAttribute("id");
			this.ChildNodes = ParseChildren(this, element.ChildNodes);

			if (!string.IsNullOrEmpty(this.Id))
			{
				this.OwnerDocument.AddIdCache(this.Id, this);
			}
		}
コード例 #9
0
        // .............................................................
        //
        // Images
        //
        // .............................................................
        private static void AddImage(XmlElement xamlParentElement, XmlElement htmlElement, IDictionary inheritedProperties, CssStylesheet stylesheet, List<XmlElement> sourceContext)
        {
            string htmlImageElementName = htmlElement.LocalName.ToLower();
            //  Implement images
            IDictionary localProperties;
            IDictionary currentProperties = GetElementProperties(htmlElement, inheritedProperties, out localProperties, stylesheet, sourceContext);
            XmlElement xamlInlineUiContainer = xamlParentElement.OwnerDocument.CreateElementNS(_xamlNamespace, Xaml_InlineUIContainer);
            XmlElement xamlImage = xamlParentElement.OwnerDocument.CreateElementNS(_xamlNamespace, Xaml_InlineUIContainer_Image);

            xamlImage.SetAttribute(Xaml_Source,htmlElement.GetAttribute("src"));
            xamlImage.SetAttribute(Xaml_Width, htmlElement.GetAttribute("width"));
              //  xamlImage.SetAttributeNS("App5.Utils", "utils:ADP.Source", "{Binding Text}");
            xamlInlineUiContainer.AppendChild(xamlImage);
            xamlParentElement.AppendChild(xamlInlineUiContainer);
        }
コード例 #10
0
ファイル: DashManifestParser.cs プロジェクト: ice0/test
        private void ParseMPDElement()
        {
            Windows.Data.Xml.Dom.XmlElement root = document.DocumentElement;
            if (root.GetAttribute("type").ToLower().Equals("dynamic"))
            {
                manifest.IsLive = true;
            }
            if (root.GetAttribute("profiles").ToLower().Contains(LiveProfile))
            {
                manifest.IsSupportedProfile = true;
            }
            if (!root.GetAttribute("availabilityStartTime").Equals(""))
            {
                string availabilityStartTime = root.GetAttribute("availabilityStartTime");
                manifest.AvailibilityStartTime = XmlConvert.ToDateTimeOffset(availabilityStartTime);
            }
            if (!root.GetAttribute("minBufferTime").Equals(""))
            {
                string minBufferTime = root.GetAttribute("minBufferTime");
                manifest.MinBufferTime = XmlConvert.ToTimeSpan(minBufferTime);
            }
            if (!root.GetAttribute("minimumUpdatePeriod").Equals(""))
            {
                manifest.HasMinimumUpdatePeriod = true;
                string minUpdatePeriod = root.GetAttribute("minimumUpdatePeriod");
                manifest.MinimumUpdatePeriod = XmlConvert.ToTimeSpan(minUpdatePeriod);
            }
            if (!root.GetAttribute("mediaPresentationDuration").Equals(""))
            {
                manifest.HasPresentationDuration = true;
                string mediaPresentationDuration = root.GetAttribute("mediaPresentationDuration");
                manifest.MediaPresentationDuration = XmlConvert.ToTimeSpan(mediaPresentationDuration);
            }
            if (!root.GetAttribute("timeShiftBufferDepth").Equals(""))
            {
                string timeShiftBufferDepth = root.GetAttribute("timeShiftBufferDepth");
                manifest.TimeShiftBufferDepth = XmlConvert.ToTimeSpan(timeShiftBufferDepth);
            }
            if (!root.GetAttribute("publishTime").Equals(""))
            {
                string publishTime = root.GetAttribute("publishTime");
                manifest.PublishTime = XmlConvert.ToDateTimeOffset(publishTime);
            }
            else
            {
                manifest.PublishTime = DateTimeOffset.MinValue;
            }
            Windows.Data.Xml.Dom.XmlNodeList periods = root.GetElementsByTagName("Period");
            if (periods.Count() > 1)
            {
                manifest.HasMultiplePeriods = true;
            }

            IXmlNode lastPeriod = periods.Last <IXmlNode>();

            if (lastPeriod.Attributes.GetNamedItem("duration") != null)
            {
                manifest.LastPeriodDuration = XmlConvert.ToTimeSpan(lastPeriod.Attributes.GetNamedItem("duration").InnerText);
            }
        }
コード例 #11
0
        public static string GetUrl(IXmlNode el, string xpath, XmlNamespaceManager nsMgr, Uri documentUri)
        {
            if (el == null)
            {
                return(null);
            }
            var node = nsMgr == null
                ? el.SelectSingleNode(xpath)
                : el.SelectSingleNodeNS(xpath, nsMgr.DefaultNamespace);

            if (node == null)
            {
                return(null);
            }
            string rawUrl = node.NodeValue.ToString();

            if (rawUrl == null || rawUrl.Length == 0)
            {
                return(null);
            }

            // optimize for common case of absolute path
            if (rawUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    return(UrlHelper.SafeToAbsoluteUri(new Uri(rawUrl)));
                }
                catch { }
            }

            ArrayList ancestors = new ArrayList();

            var parent = node.ParentNode;

            while (parent != null)
            {
                ancestors.Add(parent);
                parent = parent.ParentNode;
            }

            ancestors.Reverse();

            Uri uri = documentUri;

            foreach (var anc in ancestors)
            {
                if (anc is XmlElement)
                {
                    XmlElement baseEl = (XmlElement)anc;
                    if (baseEl.Attributes.Any(a => a.LocalName == "xml:base"))
                    {
                        string thisUri = baseEl.GetAttribute("xml:base");
                        if (uri == null)
                        {
                            uri = new Uri(thisUri);
                        }
                        else
                        {
                            uri = new Uri(uri, thisUri);
                        }
                    }
                }
            }

            if (uri == null)
            {
                return(UrlHelper.SafeToAbsoluteUri(new Uri(rawUrl)));
            }
            else
            {
                return(UrlHelper.SafeToAbsoluteUri(new Uri(uri, rawUrl)));
            }
        }
コード例 #12
0
		public SvgTransformableHelper(XmlElement element)
		{
			this.Transform = SvgTransformParser.Parse(element.GetAttribute("transform"));
		}
コード例 #13
0
ファイル: XmlTools.cs プロジェクト: salvadorjesus/Podcasts
 public static string GetAttributeValue(this Windows.Data.Xml.Dom.XmlElement node, string attributeName)
 {
     return(node.GetAttribute(attributeName));
 }
コード例 #14
0
ファイル: ChapterParser.cs プロジェクト: nguyer/OpenBible
 private static void ParseElement(XmlElement element, Chapter chapter, Style currentTextStyle)
 {
     foreach (var child in element.ChildNodes)
     {
         if (child is Windows.Data.Xml.Dom.XmlText)
         {
             if (string.IsNullOrEmpty(child.InnerText) ||
                 child.InnerText == "\n")
             {
                 continue;
             }
         }
         else if (child is XmlElement)
         {
             XmlElement e = (XmlElement)child;
             switch (e.TagName.ToUpper())
             {
                 case "DIV":
                     if (e.GetAttribute("class") == "p")
                     {
                         // Start of a new paragraph
                         chapter.Sections.Add(new Section());
                         ParseElement(e, chapter, currentTextStyle);
                     }
                     if (e.GetAttribute("class") == "s1")
                     {
                         // New heading section
                         chapter.Sections.Add(new Section());
                         ParseElement(e, chapter, currentTextStyle);
                     }
                     else
                     {
                         ParseElement(e, chapter, currentTextStyle);
                     }
                     break;
                 case "SPAN":
                     if (e.GetAttribute("class") == "heading" && element.GetAttribute("class").Contains("s1")) //(e.GetAttribute("class") == "heading")
                     {
                         chapter.Sections.Last().Heading.Add(new TextSpan(e.InnerText, currentTextStyle));
                     }
                     else if (e.GetAttribute("class") == "label" && element.GetAttribute("class").Contains("verse"))
                     {
                         Verse verse = new Verse();
                         verse.Number = int.Parse(e.InnerText);
                         chapter.Verses.Add(verse);
                         if (chapter.Sections.Count == 0)
                         {
                             chapter.Sections.Add(new Section());
                         }
                         chapter.Sections.Last().Verses.Add(verse);
                     }
                     else if (e.GetAttribute("class") == "content" && element.GetAttribute("class").Contains("verse"))
                     {
                         chapter.Verses.Last().TextSpans.Add(new TextSpan(e.InnerText, currentTextStyle));
                     }
                     else if (e.GetAttribute("class") == "content" && element.GetAttribute("class").Contains("nd"))
                     {
                         chapter.Verses.Last().TextSpans.Add(new TextSpan(e.InnerText, Style.NAME_OF_GOD));
                     }
                     else if (e.GetAttribute("class") == "heading" && element.GetAttribute("class").Contains("nd"))
                     {
                         //chapter.Sections.Last().Heading.Add(new TextSpan(e.InnerText, Style.NAME_OF_GOD));
                     }
                     else if (element.GetAttribute("class") == "q1" && e.GetAttribute("class").Contains("verse"))
                     {
                         ParseElement(e, chapter, Style.QUOTE1);
                     }
                     else if (element.GetAttribute("class") == "q2" && e.GetAttribute("class").Contains("verse"))
                     {
                         ParseElement(e, chapter, Style.QUOTE2);
                     }
                     else if (e.GetAttribute("class") == "wj" && element.GetAttribute("class").Contains("verse"))
                     {
                         chapter.Verses.Last().TextSpans.Add(new TextSpan(e.InnerText, Style.WORDS_OF_JESUS));
                     }
                     else
                     {
                         ParseElement(e, chapter, currentTextStyle);
                     }
                     break;
             }
         }
     }
 }
コード例 #15
0
        private static void ParseElement(XmlElement element, ITextContainer parent)
        {
            foreach (var child in element.ChildNodes)
            {
                if (child is Windows.Data.Xml.Dom.XmlText)
                {
                    if (string.IsNullOrEmpty(child.InnerText) ||
                        child.InnerText == "\n")
                    {
                        continue;
                    }

                    parent.Add(new Run { Text = ((XmlText)child).InnerText });
                }
                else if (child is XmlElement)
                {
                    XmlElement e = (XmlElement)child;
                    switch (e.TagName.ToUpper())
                    {
                        case "DIV":
                            if (e.GetAttribute("class") == "p")
                            {
                                Paragraph paragraph = new Paragraph();
                                paragraph.Margin = new Thickness(0, 0, 0, 10);
                                //paragraph.LineHeight = 20;
                                parent.Add(paragraph);
                                ParseElement(e, new ParagraphTextContainer(paragraph));

                            }
                            else if (e.GetAttribute("class") == "label" && element.GetAttribute("class").Contains("chapter"))
                            {
                                Paragraph chapterLabel = new Paragraph();
                                chapterLabel.FontFamily = new FontFamily("Segoe UI");
                                chapterLabel.FontSize = 32;
                                chapterLabel.Inlines.Add(new Run { Text = "Chapter " + e.InnerText });
                                parent.Add(chapterLabel);

                            }
                            else
                            {
                                ParseElement(e, parent);
                            }
                            break;
                        case "SPAN":
                            //ParseElement(e, parent);

                            if (e.GetAttribute("class") == "heading")
                            {
                                Paragraph header = new Paragraph();
                                header.FontFamily = new FontFamily("Segoe UI");
                                header.FontSize = 20;
                                header.Margin = new Thickness(0, 10, 0, 5);
                                header.Inlines.Add(new Run { Text = e.InnerText });
                                parent.Add(header);
                            }
                            else if (e.GetAttribute("class") == "label" && element.GetAttribute("class").Contains("verse"))
                            {
                                Run run = new Run();
                                run.Text = e.InnerText;
                                run.FontSize = 8;
                                parent.Add(run);
                            }
                            else
                            {
                                ParseElement(e, parent);
                            }
                            //else
                            //{
                            //    Run run = new Run();
                            //    run.Text = e.InnerText;
                            //    parent.Add(run);
                            //}
                            break;
                        case "P":
                            var p = new Paragraph();
                            parent.Add(p);
                            ParseElement(e, new ParagraphTextContainer(p));
                            break;
                        case "STRONG":
                            var bold = new Bold();
                            parent.Add(bold);
                            ParseElement(e, new SpanTextContainer(bold));
                            break;
                        case "U":
                            var underline = new Underline();
                            parent.Add(underline);
                            ParseElement(e, new SpanTextContainer(underline));
                            break;
                        case "A":
                            ParseElement(e, parent);
                            break;
                        case "BR":
                            parent.Add(new LineBreak());
                            break;
                    }
                }

            }
        }