XsltMessageEncounteredEventArgs 클래스
정의
XsltMessageEncountered 이벤트에 대한 데이터를 제공합니다.Provides data for the XsltMessageEncountered event.
public ref class XsltMessageEncounteredEventArgs abstract : EventArgs
public abstract class XsltMessageEncounteredEventArgs : EventArgs
type XsltMessageEncounteredEventArgs = class
inherit EventArgs
Public MustInherit Class XsltMessageEncounteredEventArgs
Inherits EventArgs
- 상속
예제
다음 예제에서는를 사용 XsltMessageEncounteredEventArgs 하 여 xsl:message
콘솔에 콘텐츠를 표시 합니다.The following example uses the XsltMessageEncounteredEventArgs to display xsl:message
content to the console. 샘플은 콘솔에 다음 메시지를 씁니다 Message received: Author name is not in the correct format <author><name>Plato</name></author>
.The sample writes the following message to the console: Message received: Author name is not in the correct format <author><name>Plato</name></author>
.
using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
public class Sample {
public static void Main() {
// Create the XslCompiledTransform object and load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("message.xsl");
XsltArgumentList argList = new XsltArgumentList();
argList.XsltMessageEncountered += new XsltMessageEncounteredEventHandler(MessageCallBack);
// Load the file to transform.
XPathDocument doc = new XPathDocument("books.xml");
// Transform the file.
xslt.Transform(doc, argList, XmlWriter.Create("output.xml"));
}
private static void MessageCallBack(object sender, XsltMessageEncounteredEventArgs e) {
Console.WriteLine("Message received: {0}", e.Message);
}
}
Imports System.IO
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.XPath
Public Class Sample
Public Shared Sub Main()
' Create the XslCompiledTransform object and load the style sheet.
Dim xslt As New XslCompiledTransform()
xslt.Load("message.xsl")
Dim argList As New XsltArgumentList()
AddHandler argList.XsltMessageEncountered, AddressOf MessageCallBack
' Load the file to transform.
Dim doc As New XPathDocument("books.xml")
' Transform the file.
xslt.Transform(doc, argList, XmlWriter.Create("output.xml"))
End Sub
Private Shared Sub MessageCallBack(ByVal sender As Object, ByVal e As XsltMessageEncounteredEventArgs)
Console.WriteLine("Message received: {0}", e.Message)
End Sub
End Class
이 예제에서는 다음 파일을 입력으로 사용 합니다.The example uses the following files as input:
books.xmlbooks.xml
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
메시지 .xslmessage.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="//author"/>
</xsl:template>
<xsl:template match="author">
<xsl:if test="not (last-name)">
<xsl:message terminate="no">Author name is not in the correct format <xsl:copy-of select="."/>
</xsl:message>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
설명
XsltMessageEncountered이 이벤트는 xsl:message
가 스타일 시트에 지정 된 경우 XSLT 처리 중에 발생 합니다.The XsltMessageEncountered event occurs during XSLT processing when an xsl:message
is specified in the style sheet.
참고
terminate
특성이로 설정 된 경우 "yes"
XSLT 프로세서는 메시지 처리 후에 스타일 시트의 실행을 중지 합니다.If the terminate
attribute is set to "yes"
, the XSLT processor stops executing the style sheet stops after the message is processed.
생성자
XsltMessageEncounteredEventArgs() |
XsltMessageEncounteredEventArgs 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the XsltMessageEncounteredEventArgs class. |
속성
Message |
|
메서드
Equals(Object) |
지정된 개체가 현재 개체와 같은지 확인합니다.Determines whether the specified object is equal to the current object. (다음에서 상속됨 Object) |
GetHashCode() |
기본 해시 함수로 작동합니다.Serves as the default hash function. (다음에서 상속됨 Object) |
GetType() |
현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance. (다음에서 상속됨 Object) |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object. (다음에서 상속됨 Object) |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object. (다음에서 상속됨 Object) |