Share via


XDocumentType.SystemId 속성

정의

이 DTD(문서 종류 정의)의 시스템 식별자를 가져오거나 설정합니다.

public:
 property System::String ^ SystemId { System::String ^ get(); void set(System::String ^ value); };
public string SystemId { get; set; }
public string? SystemId { get; set; }
member this.SystemId : string with get, set
Public Property SystemId As String

속성 값

String

이 DTD(문서 종류 정의)의 시스템 식별자가 들어 있는 String입니다.

예제

다음 예제에서는 외부 프라이빗 DTD를 참조하는 XML 문서를 만듭니다. DTD에는 내부 하위 집합이 없습니다. 생성자에 대한 XDocumentType 호출은 외부 프라이빗 DTD의 사용을 반영합니다. 내부 하위 집합에 대해 전달됩니다 null .

string pubsDtd =  
@"<!ELEMENT Pubs (Book+)>  
<!ELEMENT Book (Title, Author)>  
<!ELEMENT Title (#PCDATA)>  
<!ELEMENT Author (#PCDATA)>";  
File.WriteAllText("Pubs.dtd", pubsDtd);  

string target = "xml-stylesheet";  
string data = "href=\"mystyle.css\" title=\"Compact\" type=\"text/css\"";  

XDocument doc = new XDocument(  
    new XDocumentType("Pubs", null, "Pubs.dtd", null),  
    new XElement("Pubs",   
        new XElement("Book",  
            new XElement("Title", "Artifacts of Roman Civilization"),  
            new XElement("Author", "Moreno, Jordao")  
        ),  
        new XElement("Book",  
            new XElement("Title", "Midieval Tools and Implements"),  
            new XElement("Author", "Gazit, Inbar")  
        )  
    ),  
    new XComment("This is another comment.")  
);  
doc.Declaration = new XDeclaration("1.0", "utf-8", "true");  
doc.Save("Pubs.xml");  

// Validate Pubs.xml against Pubs.dtd.  
XmlReaderSettings xrs = new XmlReaderSettings();  
xrs.ProhibitDtd = false;  
xrs.ValidationType = ValidationType.DTD;  
xrs.ConformanceLevel = ConformanceLevel.Auto;  
XmlReader xr = XmlReader.Create("Pubs.xml", xrs);  
XDocument doc2 = XDocument.Load(xr);  

XDocumentType dt = doc2.Document.DocumentType;  
Console.WriteLine("SystemId:{0}", dt.SystemId);  
Dim pubsDtd As String = _   
    "<!ELEMENT Pubs (Book+)>" & Environment.NewLine & _  
    "<!ELEMENT Book (Title, Author)>" & Environment.NewLine & _  
    "<!ELEMENT Title (#PCDATA)>" & Environment.NewLine & _  
    "<!ELEMENT Author (#PCDATA)>"  
File.WriteAllText("Pubs.dtd", pubsDtd)  

Dim target As String = "xml-stylesheet"  
Dim data As String = "href='mystyle.css' title='Compact' type='text/css'"  

Dim doc As XDocument = _  
    <?xml version='1.0'?>  
    <Pubs>  
        <Book>  
            <Title>Artifacts of Roman Civilization</Title>  
            <Author>Moreno, Jordao</Author>  
        </Book>  
        <Book>  
            <Title>Midieval Tools and Implements</Title>  
            <Author>Gazit, Inbar</Author>  
        </Book>  
    </Pubs>  
    <!--This is another comment.-->  

doc _  
.FirstNode _  
.AddBeforeSelf(New XDocumentType("Pubs", Nothing, "Pubs.dtd", Nothing))  

doc.Declaration = New XDeclaration("1.0", "utf-8", "true")  
doc.Save("Pubs.xml")  

' Validate Pubs.xml against Pubs.dtd.  
Dim xrs As XmlReaderSettings = New XmlReaderSettings()  
xrs.ProhibitDtd = False  
xrs.ValidationType = ValidationType.DTD  
xrs.ConformanceLevel = ConformanceLevel.Auto  
Dim xr As XmlReader = XmlReader.Create("Pubs.xml", xrs)  
Dim doc2 As XDocument = XDocument.Load(xr)  

Dim dt As XDocumentType = doc2.Document.DocumentType  
Console.WriteLine("SystemId:{0}", dt.SystemId)  

이 예제는 다음과 같은 출력을 생성합니다.

SystemId:Pubs.dtd  

설명

XML 문서에서 외부 개인 DTD를 사용하는 경우 이 속성에는 외부 DTD의 개인 식별자가 포함됩니다.

적용 대상

추가 정보