ResolveUri() публичный Метод

public ResolveUri ( Uri baseUri, string relativeUri ) : Uri
baseUri Uri
relativeUri string
Результат Uri
Пример #1
0
 public override Uri ResolveUri(Uri baseUri, string relativeUri)
 {
     return(resolver.ResolveUri(baseUri, relativeUri));
 }
        private void SetupValidation(ValidationType valType)
        {
            validator = BaseValidator.CreateInstance(valType, this, schemaCollection, eventHandling, processIdentityConstraints);

            XmlResolver resolver = GetResolver();

            validator.XmlResolver = resolver;

            if (outerReader.BaseURI.Length > 0)
            {
                validator.BaseUri = (resolver == null) ? new Uri(outerReader.BaseURI, UriKind.RelativeOrAbsolute) : resolver.ResolveUri(null, outerReader.BaseURI);
            }
            coreReaderImpl.ValidationEventHandling = (validationType == ValidationType.None) ? null : eventHandling;
        }
Пример #3
0
		private string GetResolvedUri (XmlResolver resolver, string relativeUri)
		{
			Uri baseUri = null;
			if (this.SourceUri != null && this.SourceUri != String.Empty)
				baseUri = new Uri (this.SourceUri);
			Uri abs = resolver.ResolveUri (baseUri, relativeUri);
#if NET_2_0
			return abs != null ? abs.OriginalString : String.Empty;
#else
 			return abs != null ? abs.ToString () : String.Empty;
#endif
		}
Пример #4
0
 // SxS: URIs are resolved only to be compared. No resource exposure. It's OK to suppress the SxS warning.
 private bool UriEqual(Uri uri1, string uri1Str, string uri2Str, XmlResolver resolver)
 {
     if (resolver == null)
     {
         return uri1Str == uri2Str;
     }
     if (uri1 == null)
     {
         uri1 = resolver.ResolveUri(null, uri1Str);
     }
     Uri uri2 = resolver.ResolveUri(null, uri2Str);
     return uri1.Equals(uri2);
 }
Пример #5
0
        // Initializes a new instance of the XmlTextReaderImpl class with the specified arguments.
        // This constructor is used when creating XmlTextReaderImpl via XmlReader.Create
        internal XmlTextReaderImpl(string uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
            : this(settings.GetXmlResolver(), settings, context)
        {
            Uri baseUri = uriResolver.ResolveUri(null, uriStr);
            string baseUriStr = baseUri.ToString();

            // get BaseUri from XmlParserContext
            if (context != null)
            {
                if (context.BaseURI != null && context.BaseURI.Length > 0 &&
                    !UriEqual(baseUri, baseUriStr, context.BaseURI, settings.GetXmlResolver()))
                {
                    if (baseUriStr.Length > 0)
                    {
                        Throw(SR.Xml_DoubleBaseUri);
                    }
                    Debug.Assert(baseUri == null);
                    baseUriStr = context.BaseURI;
                }
            }

            _reportedBaseUri = baseUriStr;
            _closeInput = true;
            _laterInitParam = new LaterInitParam();
            _laterInitParam.inputUriStr = uriStr;
            _laterInitParam.inputbaseUri = baseUri;
            _laterInitParam.inputContext = context;
            _laterInitParam.inputUriResolver = uriResolver;
            _laterInitParam.initType = InitInputType.UriString;
            if (!settings.Async)
            {
                //if not set Async flag, finish the init in create stage.
                FinishInitUriString();
            }
            else
            {
                _laterInitParam.useAsync = true;
            }
        }
Пример #6
0
        public void ReadXml(XPathNavigator node, XmlResolver resolver)
        {
            if (node.NodeType == XPathNodeType.Element) {

            XPathNavigator el = node.Clone();

            if (node.MoveToFirstAttribute()) {

               do {
                  switch (node.LocalName) {
                     case "byte-order-mark":
                        this.ByteOrderMark = node.ValueAsBoolean;
                        break;

                     case "doctype-public":
                        this.DocTypePublic = node.Value;
                        break;

                     case "doctype-system":
                        this.DocTypeSystem = node.Value;
                        break;

                     case "encoding":
                        this.Encoding = Encoding.GetEncoding(node.Value);
                        break;

                     case "indent":
                        this.Indent = node.ValueAsBoolean;
                        break;

                     case "media-type":
                        this.MediaType = node.Value;
                        break;

                     case "method":

                        if (node.Value.Contains(":")) {

                           string name = XmlConvert.VerifyName(node.Value);
                           string[] parts = name.Split(':');

                           string local = parts[1];
                           string ns = node.LookupNamespace(parts[0]) ?? "";

                           XmlQualifiedName qname = new XmlQualifiedName(local, ns);

                           if (ns != null
                              && (qname == ExtensionMethods.Base64Binary
                                 || qname == ExtensionMethods.HexBinary)) {
                              this.Method = qname;
                           } else {
                              throw new ArgumentException("The value of the method attribute must be one of: xml, html, xhtml, text, http:base64Binary or http:hexBinary.", "node");
                           }

                        } else {

                           switch (node.Value) {
                              case "xml":
                                 this.Method = XPathSerializationMethods.Xml;
                                 break;

                              case "html":
                                 this.Method = XPathSerializationMethods.Html;
                                 break;

                              case "xhtml":
                                 this.Method = XPathSerializationMethods.XHtml;
                                 break;

                              case "text":
                                 this.Method = XPathSerializationMethods.Text;
                                 break;

                              default:
                                 throw new ArgumentException("The value of the method attribute must be one of: xml, html, xhtml, text, http:base64Binary or http:hexBinary.", "node");
                           }
                        }
                        break;

                     case "omit-xml-declaration":
                        this.OmitXmlDeclaration = node.ValueAsBoolean;
                        break;

                     case "src":

                        Uri elBaseUri = !String.IsNullOrEmpty(el.BaseURI) ?
                           new Uri(el.BaseURI) :
                           null;

                        if (resolver != null) {
                           this.Src = resolver.ResolveUri(elBaseUri, node.Value);
                        } else {
                           this.Src = (elBaseUri != null) ?
                              new Uri(elBaseUri, node.Value) :
                              new Uri(node.Value);
                        }

                        break;

                     default:
                        break;
                  }

               } while (node.MoveToNextAttribute());

               node.MoveToParent();
            }

            if (node.MoveToFirstChild()) {

               do {
                  if (node.NodeType == XPathNodeType.Element || node.NodeType == XPathNodeType.Text) {
                     this.Content = node.Clone();
                     break;
                  }

               } while (node.MoveToNext());

               node.MoveToParent();
            }
             }
        }
Пример #7
0
 public static XPathDocument LoadDoc(string name, XmlResolver resolver){
     var uri = resolver.ResolveUri(null, name);
     var s = resolver.GetEntity(uri, "", typeof (Stream)) as Stream;
     return GetDoc(s);
 }