XmlUrlResolver.GetEntity メソッド
アセンブリ: 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: virtual Object^ GetEntity ( Uri^ absoluteUri, String^ role, Type^ ofObjectToReturn ) override
public override function GetEntity ( absoluteUri : Uri, role : String, ofObjectToReturn : Type ) : Object
- role
現在の実装は、URI を解決するときにこのパラメータを使用しません。このパラメータは、将来の拡張のために提供されています。たとえば、このパラメータを xlink:role に割り当て、別の場合に実装固有の引数として使用できます。
System.IO.Stream オブジェクト。ストリーム以外の型が指定された場合は null 参照 (Visual Basic では Nothing)。


呼び出し元が指定した URI が表す実際のリソースを含むオブジェクトにその URI を割り当てるとき、このメソッドが使用されます。
![]() |
---|
GetEntity メソッドでは、メモリの飽和をねらった DoS 攻撃が懸念されます。ラッピング実装された IStream をアプリケーションで実装し、読み取るバイト数を制限することにより、このような脅威を緩和できます。これにより、膨大なバイト ストリームを GetEntity メソッドに渡すような悪質なコードに備えることができます。 |

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- XmlUrlResolver.GetEntity メソッドのページへのリンク