XSL Transformとは? わかりやすく解説

XslTransform クラス

メモ : このクラスは、互換性のために残されています。

XSLT (Extensible Stylesheet Language Transformations) スタイル シート使用して XML データ変換します

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

<ObsoleteAttribute("This class has been deprecated. Please
 use System.Xml.Xsl.XslCompiledTransform instead. http://go.microsoft.com/fwlink/?linkid=14202")>
 _
Public NotInheritable Class
 XslTransform
[ObsoleteAttribute("This class has been deprecated. Please
 use System.Xml.Xsl.XslCompiledTransform instead. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public sealed class XslTransform
[ObsoleteAttribute(L"This class has been deprecated. Please
 use System.Xml.Xsl.XslCompiledTransform instead. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public ref class XslTransform sealed
/** @attribute ObsoleteAttribute("This class has been deprecated.
 Please use System.Xml.Xsl.XslCompiledTransform instead. http://go.microsoft.com/fwlink/?linkid=14202")
 */ 
public final class XslTransform
ObsoleteAttribute("This class has been deprecated. Please
 use System.Xml.Xsl.XslCompiledTransform instead. http://go.microsoft.com/fwlink/?linkid=14202")
 
public final class XslTransform
解説解説
メモメモ

XslTransform クラスは、Microsoft .NET Framework Version 2.0 では使用されなくなりました。XslCompiledTransform クラスは、新しXSLT プロセッサです。詳細については、XslCompiledTransform クラス使用、XslTransform クラスからの移行 の各トピック参照してください

XslTransform は、XSLT 1.0 構文サポートしてます。XSLT スタイル シートでは、名前空間 http://www.w3.org/1999/XSL/Transform使用する必要があります

XsltArgumentList クラス使用して引数スタイル シート追加することもできます。このクラスには、スタイル シート入力パラメータと、スタイル シートから呼び出すことができる拡張機能オブジェクト含まれています。

XML データ変換するには、次を実行します

  1. XslTransform オブジェクト作成します

  2. Load メソッド使用して変換用のスタイル シート読み込みます。このメソッド複数オーバーロード持ちXmlReader、XPathNavigator、IXPathNavigable、またはファイル位置を含む URL使用してスタイル シート読み込むことができます

  3. Transform メソッド使用してXML データ変換します。このメソッドオーバーロード持ち異なる型の入出力を処理できます追加引数を含む XsltArgumentList指定して変換中に入力として使用することもできます

セキュリティについての考慮事項

XslTransform クラス使用するアプリケーション作成する場合は、次の項目とその影響注意してください

これらのセキュリティの問題は、信頼できないソースからの XslTransform オブジェクトXSLT スタイル シート、または XML ソース データ受け入れないことで軽減できます

スクリプトサポート

このクラスは、msxsl:script 要素使用して埋め込まれスクリプトサポートします

.NET Framework Version 1.1 では、スタイル シート証拠によって、埋め込みスクリプト与えられるアクセス許可決まります

信頼度の低い呼び出し元の場合 : 埋め込みスクリプトコンパイルするには UnmanagedCode アクセス許可が必要です。Load メソッドEvidence指定するには ControlEvidence アクセス許可が必要です。必要なアクセス許可呼び出し元にない場合は SecurityException がスローさます。詳細については、System.Security.Permissions.SecurityPermission と System.Security.Permissions.SecurityPermissionFlag のトピック参照してください

msxsl:script 要素には次の要件あります

Note スクリプト ブロックを CDATA セクションラップすることをお勧めます。

 <msxsl:script implements-prefix='xy' language='C#'>
   <![CDATA[
   // Add code here.
   ]]>
 </msxsl:script>

関数は、msxsl:script 要素内で宣言できます既定サポートされ名前空間次の表に示します

スクリプト関数定義された、提供される引数戻り値は、次に示す W3C (World Wide Web Consortium) 仕様の型のいずれかである必要がありますW3C 仕様の型 (XPath または XSLTいずれか) と、対応する .NET Framework クラス間のマップ詳細次の表に示します

W3C 仕様の型

等価.NET クラス

文字列 (XPath)

System.String

ブール値 (XPath)

System.Boolean

数値 (XPath)

System.Double

結果木素片 (XSLT)

System.Xml.XPath.XPathNavigator

ノード集合 (XPath)

System.Xml.XPath.XPathNodeIterator

スクリプト関数で、Int16、UInt16、Int32、UInt32、Int64、UInt64、単精度浮動小数点型、または 10 進いずれか数値型使用されている場合、これらの型は強制的に倍精度浮動小数点型に変換されW3C XPath 型の数値割り当てられます。

引数結果必要な型に変換できない関数呼び出されると、例外スローさます。

メモメモ

msxsl:scriptmsxsl:node-list は、urn:schemas-microsoft-com:xslt 名前空間唯一の関数で、XslTransform クラスによってサポートされます。

XslTransform には、拡張機構として共通言語ランタイム (CLR) コード利用する機能用意されています。これは、クラスインスタンスXslTransform クラス渡して、そのパブリック メソッドXSLT スタイル シート内で呼び出すことによって実行されます。params キーワードを使用すると、数を指定せずにパラメータを渡すことができますが、このキーワードで定義されるメソッドはこのシナリオでは正しく動作しません。詳細については、params (C# リファレンス) のトピック参照してください

詳細については、「XslTransform クラス使用した XSLT 変換」を参照してください

使用例使用例

指定した XML ドキュメント変換しその結果コンソール出力する例を次に示します

'Create a new XslTransform object.
Dim xslt As New XslTransform()

'Load the stylesheet.
xslt.Load(CType("http://server/favorite.xsl", String))

'Create a new XPathDocument and load the XML data to be transformed.
Dim mydata As New XPathDocument("inputdata.xml")

'Create an XmlTextWriter which outputs to the console.
Dim writer As New XmlTextWriter(Console.Out)

'Transform the data and send the output to the console.
xslt.Transform(mydata, Nothing, writer, Nothing)
//Create a new XslTransform object.
XslTransform xslt = new XslTransform();

//Load the stylesheet.
xslt.Load("http://server/favorite.xsl");

//Create a new XPathDocument and load the XML data to be transformed.
XPathDocument mydata = new XPathDocument("inputdata.xml");

//Create an XmlTextWriter which outputs to the console.
XmlWriter writer = new XmlTextWriter(Console.Out);

//Transform the data and send the output to the console.
xslt.Transform(mydata,null,writer, null);
//Create a new XslTransform object.
XslTransform^ xslt = gcnew XslTransform;

//Load the stylesheet.
xslt->Load( "http://server/favorite.xsl" );

//Create a new XPathDocument and load the XML data to be transformed.
XPathDocument^ mydata = gcnew XPathDocument( "inputdata.xml" );

//Create an XmlTextWriter which outputs to the console.
XmlWriter^ writer = gcnew XmlTextWriter( Console::Out );

//Transform the data and send the output to the console.
xslt->Transform^(mydata,0,writer,0);
//Create a new XslTransform object.
XslTransform xslt = new XslTransform();

//Load the stylesheet.
xslt.Load("http://server/favorite.xsl");

//Create a new XPathDocument and load the XML data to be transformed.
XPathDocument myData = new XPathDocument("inputdata.xml");

//Create an XmlTextWriter which outputs to the console.
XmlWriter writer = new XmlTextWriter(Console.get_Out());

//Transform the data and send the output to the console.
xslt.Transform(myData, null, writer, null);
継承階層継承階層
System.Object
  System.Xml.Xsl.XslTransform
スレッド セーフスレッド セーフ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XslTransform メンバ
System.Xml.Xsl 名前空間

XslTransform コンストラクタ


XslTransform プロパティ


XslTransform メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

XslTransform クラス
System.Xml.Xsl 名前空間

XslTransform メンバ

XSLT (Extensible Stylesheet Language Transformations) スタイル シート使用して XML データ変換します

XslTransform データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド XslTransform XslTransform クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

XslTransform クラス
System.Xml.Xsl 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「XSL Transform」の関連用語

XSL Transformのお隣キーワード
検索ランキング

   

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



XSL Transformのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS