public virtual void HandlesAbsPrefixOnHasAttr() { // 1: no abs url; 2: has abs url Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<a id=1 href='/foo'>One</a> <a id=2 href='http://jsoup.org/'>Two</a>" ); iText.StyledXmlParser.Jsoup.Nodes.Element one = doc.Select("#1").First(); iText.StyledXmlParser.Jsoup.Nodes.Element two = doc.Select("#2").First(); NUnit.Framework.Assert.IsFalse(one.HasAttr("abs:href")); NUnit.Framework.Assert.IsTrue(one.HasAttr("href")); NUnit.Framework.Assert.AreEqual("", one.AbsUrl("href")); NUnit.Framework.Assert.IsTrue(two.HasAttr("abs:href")); NUnit.Framework.Assert.IsTrue(two.HasAttr("href")); NUnit.Framework.Assert.AreEqual("http://jsoup.org/", two.AbsUrl("href")); }
public virtual void HandlesAbsPrefix() { Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<a href=/foo>Hello</a>", "http://jsoup.org/"); iText.StyledXmlParser.Jsoup.Nodes.Element a = doc.Select("a").First(); NUnit.Framework.Assert.AreEqual("/foo", a.Attr("href")); NUnit.Framework.Assert.AreEqual("http://jsoup.org/foo", a.Attr("abs:href")); NUnit.Framework.Assert.IsTrue(a.HasAttr("abs:href")); }
public virtual void LiteralAbsPrefix() { // if there is a literal attribute "abs:xxx", don't try and make absolute. Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<a abs:href='odd'>One</a>"); iText.StyledXmlParser.Jsoup.Nodes.Element el = doc.Select("a").First(); NUnit.Framework.Assert.IsTrue(el.HasAttr("abs:href")); NUnit.Framework.Assert.AreEqual("odd", el.Attr("abs:href")); }