<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
속성 이름 = '속성값의 쌍으로 제공되어야 한다.
<?xml version="1.0" encoding="euc-kr" standalone="yes"?>
<?xml-stylesheet href="entityExample.css" type="text/css"?>
<MEMO>
<TO> to : " Eugene "</TO>
<FROM>From : Hong, Gil-Dong</FROM>
<CONTENTS>Can we dine out at 1 PM?</CONTENTS>
</MEMO>
*{
display: block;
}TO, FROM{
font-weight: bold;
}
CONTENTS {
color : red;
font-style: italic;
margin-top: 15px;
margin-left: 10px;
}

<?xml version="1.0" encoding="UTF-8"?>
<user>
<name>John Doe</name>
<email>john.doe@example.com</email>
<bio>I am a <strong>software developer</strong> with 5+ years of experience.</bio>
<skills>
<skill>Java</skill>
<skill>Python</skill>
<skill>XML & JSON</skill>
</skills>
</user>

<?xml version="1.0" encoding="UTF-8"?>
<script>
<javascript><![CDATA[
function greet(name) {
if (name != null && name.length > 0) {
alert("Hello, " + name + "!");
} else {
alert("Hello, stranger!");
}
}
// Call the function
greet("John");
]]></javascript>
</script>

<?xml version="1.0" encoding="UTF-8"?>
<example>
<pcdata_section>
<description>This is a PCDATA section. Special characters need to be escaped:</description>
<code>if (x < 10 && y > 20) { alert("Hello!"); }</code>
</pcdata_section>
<cdata_section>
<description>This is a CDATA section. Special characters do not need to be escaped:</description>
<code><![CDATA[if (x < 10 && y > 20) { alert("Hello!"); }]]></code>
</cdata_section>
</example>

<!ELEMENT 엘리먼트이름 내용모델><!-- 1. 빈 엘리먼트 -->
<!ELEMENT br EMPTY>
EMPTY: 내용이 없는 빈 엘리먼트를 선언.
<!-- 2. 텍스트만 포함하는 엘리먼트 -->
<!ELEMENT title (#PCDATA)>
(#PCDATA): 텍스트만 포함하는 엘리먼트를 선언.
<!-- 3. 자식 엘리먼트를 포함하는 엘리먼트 -->
<!ELEMENT book (title, author, year)>
자식 엘리먼트 나열: 특정 순서의 자식 엘리먼트를 포함하는 엘리먼트를 선언.
<!-- 4. 혼합 콘텐츠 엘리먼트 -->
<!ELEMENT paragraph (#PCDATA | emphasis | strong)*>
혼합 콘텐츠: 텍스트와 다른 엘리먼트를 함께 포함할 수 있는 엘리먼트를 선언.
<!-- 5. ANY 내용을 가진 엘리먼트 -->
<!ELEMENT note ANY>
ANY: 어떤 내용이든 포함할 수 있는 엘리먼트를 선언.
<!-- 6. 선택적 및 반복 자식 엘리먼트 -->
<!ELEMENT person (name, age?, (address | phone)*)>
특수 문자 사용:
?: 선택적 (0 또는 1번 출현)
*: 0번 이상 반복
+: 1번 이상 반복
|: OR 연산자 (둘 중 하나 선택)
<note day = "12" month = "11" year = "2022" to = "Tove" from = "Jani" heading = "REminder" body = "Don't forget me this weekend!">
: 이미지에서 보이는 메시지는 "XML은 이렇게 사용되어서는 안 된다"는 내용이다.. 구체적으로 <note> 태그에 여러 개의 속성이 들어 있는데, 내용(body)을 속성으로 정의한 것이 문제. XML에서 이런 방식은 잘못된 사용법이다.
<note day="12" month="11" year="2002" to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!" >
</note>
<note day="12" month="11" year="2002" to="Tove" from="Jani" heading="Reminder">
<body>Don't forget me this weekend!</body>
</note>

: 문자열 데이터를 허용하는 타입.
: 정의된 엔티티를 참조하는 타입.
: 고유한 식별자를 할당하는 타입. 각 요소에서 유일해야 함.
<?xml version="1.0"?>
<!-- <?xml-stylesheet type = "text/css" href = "memoEntity.css"?> -->
<!DOCTYPE myMessage [
<!ELEMENT myMessage ( message )>
<!ELEMENT message ( #PCDATA )>
<!ENTITY myEntityA "Entity Value A">
<!ATTLIST message id CDATA #REQUIRED>
]>
<myMessage>
<message id="445 myEntityA"> Welcome to XML! &myEntityA; </message>
</myMessage>

: 다른 ID 값을 참조하는 속성.
: 하나 이상의 ID 값을 참조하는 속성.
<?xml version="1.0"?>
<!DOCTYPE bookstore [
<!ELEMENT bookstore (shipping+, book+)>
<!ELEMENT shipping (duration)>
<!ATTLIST shipping shipID ID #REQUIRED>
<!ELEMENT duration (#PCDATA)> <!-- duration 요소 선언 추가 -->
<!ELEMENT book (#PCDATA)>
<!ATTLIST book shippedBy IDREF #IMPLIED>
<!ATTLIST book shippedBys IDREFS #IMPLIED>
]>
<bookstore>
<shipping shipID="s1">
<duration>2 to 4 days</duration>
</shipping>
<shipping shipID="s2">
<duration>1 day</duration>
</shipping>
<book shippedBy="s2"> Java How to Program 3rd edition. </book>
<book shippedBys="s1 s2"> Java How to Program 3rd edition. </book>
</bookstore>

: 이름 토큰으로 허용되는 값 (공백 없이 하나의 문자열).
: 여러 개의 이름 토큰 (공백으로 구분된 문자열 목록).
<!DOCTYPE example [
<!ELEMENT example (name, tags)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT tags (#PCDATA)>
<!ATTLIST example
id NMTOKEN #REQUIRED
categories NMTOKENS #IMPLIED
>
]>
<example id="item123" categories="tag1 tag2 tag3">
<name>Sample Item</name>
<tags>Tags related to the item</tags>
</example>

<?xml version="1.0"?>
<!DOCTYPE myMessage [
<!ELEMENT myMessage ( message )>
<!ELEMENT message ( #PCDATA )>
<!ATTLIST message id NMTOKENS #REQUIRED>
<!ATTLIST message select (yes | no) "no" >
]>
<myMessage>
<message id="445 abc" select="yes"> Welcome to XML! </message>
</myMessage>