XmlUrlResolver.GetEntity メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlUrlResolver.GetEntity メソッドの意味・解説 

XmlUrlResolver.GetEntity メソッド

URI を実際のリソースを含むオブジェクトに割り当てます。

名前空間: System.Xml
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

Public Overrides Function
 GetEntity ( _
    absoluteUri As Uri, _
    role As String, _
    ofObjectToReturn As Type _
) As Object
Dim instance As XmlUrlResolver
Dim absoluteUri As Uri
Dim role As String
Dim ofObjectToReturn As Type
Dim returnValue As Object

returnValue = instance.GetEntity(absoluteUri, role, ofObjectToReturn)
public override Object GetEntity (
    Uri absoluteUri,
    string role,
    Type ofObjectToReturn
)
public:
virtual Object^ GetEntity (
    Uri^ absoluteUri, 
    String^ role, 
    Type^ ofObjectToReturn
) override
public Object GetEntity (
    Uri absoluteUri, 
    String role, 
    Type ofObjectToReturn
)
public override function GetEntity (
    absoluteUri : Uri, 
    role : String, 
    ofObjectToReturn : Type
) : Object

パラメータ

absoluteUri

ResolveUri から返された URI。

role

現在の実装は、URI を解決するときにこのパラメータを使用しません。このパラメータは、将来の拡張のために提供されています。たとえば、このパラメータを xlink:role に割り当て、別の場合に実装固有の引数として使用できます。

ofObjectToReturn

返すオブジェクトの型。現在の実装だけが、System.IO.Stream オブジェクトを返します。

戻り値
System.IO.Stream オブジェクト。ストリーム以外の型が指定された場合は null 参照 (Visual Basic では Nothing)。

例外例外
例外の種類条件

XmlException

ofObjectToReturn が null 参照 (Visual Basic では Nothing) でも Stream 型でもありません。

UriFormatException

指定した URI が絶対 URI ではありません。

NullReferenceException

absoluteUri が null 参照 (Visual Basic では Nothing) です。

Exception

ランタイム エラー (サーバー接続の中断など) があります。

解説解説
使用例使用例

GetEntity メソッドと ResolveUri メソッドの例を次に示します。

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    
  Public Shared Sub Main()

     Dim resolver As New
 XmlUrlResolver()
     Dim baseUri As New
 Uri("http://servername/tmp/test.xsl")
     Dim fulluri As Uri = resolver.ResolveUri(baseUri,
 "includefile.xsl")
            
     ' Get a stream object containing the XSL file
     Dim s As Stream = CType(resolver.GetEntity(fulluri,
 Nothing, GetType(Stream)), Stream)
            
     ' Read the stream object displaying the contents of the XSL file
     Dim reader As New XmlTextReader(s)
     While reader.Read()
        Console.WriteLine(reader.ReadOuterXml())
     End While
        
  End Sub 'New 
End Class 'Sample
using System;
using System.IO;
using System.Xml;
 
 public class Sample
 {
          
   public static void Main()
   {
       XmlUrlResolver resolver = new XmlUrlResolver();
 
       Uri baseUri = new Uri ("http://servername/tmp/test.xsl");
 
       Uri fulluri=resolver.ResolveUri(baseUri, "includefile.xsl");
 
       // Get a stream object containing the XSL file
       Stream s=(Stream)resolver.GetEntity(fulluri, null, typeof(Stream));
 
       // Read the stream object displaying the contents of the XSL
 file
       XmlTextReader reader = new XmlTextReader(s);
       while (reader.Read()) 
       {
          Console.WriteLine(reader.ReadOuterXml());
       } 
   }
}
#using <System.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;

int main()
{
   XmlUrlResolver^ resolver = gcnew XmlUrlResolver;
   Uri^ baseUri = gcnew Uri( "http://servername/tmp/test.xsl"
 );
   Uri^ fulluri = resolver->ResolveUri( baseUri, "includefile.xsl" );

   // Get a stream object containing the XSL file
   Stream^ s = dynamic_cast<Stream^>(resolver->GetEntity( fulluri, nullptr,
 Stream::typeid ));

   // Read the stream object displaying the contents of the XSL file
   XmlTextReader^ reader = gcnew XmlTextReader( s );
   while ( reader->Read() )
   {
      Console::WriteLine( reader->ReadOuterXml() );
   }
}
import System.*;
import System.IO.*;
import System.Xml.*;

public class Sample
{    
    public static void main(String[]
 args)
    {
        XmlUrlResolver resolver =  new XmlUrlResolver();
        Uri baseUri =  new Uri("http://servername/tmp/test.xsl");
        Uri fullUri = resolver.ResolveUri(baseUri, "includefile.xsl");

        // Get a stream object containing the XSL file
        Stream s = ((Stream)(resolver.GetEntity(fullUri, null
,
            Stream.class.ToType())));

        // Read the stream object displaying the contents of the XSL
 file
        XmlTextReader reader =  new XmlTextReader(s);
        while(reader.Read()) {
            Console.WriteLine(reader.ReadOuterXml());
        }
    } //main
} //Sample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「XmlUrlResolver.GetEntity メソッド」の関連用語

XmlUrlResolver.GetEntity メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlUrlResolver.GetEntity メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS