Recent posts

Recent comments

Archive

Calender

«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

출처 : w3schools - XML Elements(영문)


위 사이트의 내용을, 내맘대로 해석함. ─.─;;


What is an XML Element?

“엘리먼트”란 무엇인가


An XML element is everything from (including) the element's start tag to (including) the element's end tag.
XML에서 엘리먼트란, 시작 태그와 끝 태그를 포함해서, 그 사이에 들어가는 모든 것을 말한다.


An element can contain:
엘리먼트는 아래의 것들을 포함할 수 있다.

other elements 다른 엘리먼트
text 텍스트 (문자)
attributes 속성
or a mix of all of the above... 또는 위의 것들이 전부 결합된 형태



In the example above,
<bookstore> and <book> have element contents, because they contain other elements.
<book> also has an attribute (category="CHILDREN").
<title>, <author>, <year>, and <price> have text content because they contain text.


위의 예문에서,
<bookstore>와 <book>에는 다른 엘리먼트들이 들어있기에, 엘리먼트 콘텐츠를 가지고 있는 것이다.
<book>에는 속성도 설정되어 있다. (“CHILDREN”이라는 값을 가지고 있는 category 속성)
<title>과 <author>, <year>, <price>에는 텍스트가 들어있기에, 텍스트 콘텐츠를 가지고 있다 하겠다.


Empty XML Elements

XML의 “빈 엘리먼트”


An element with no content is said to be empty.
(아래와 같이) 아무것도 없는 엘리먼트를 “빈 엘리먼트”라고 부른다.




or you can use an empty tag, like this (this sort of element syntax is called self-closing):
또는 빈 태그를 아래와 같이 작성할 수도 있다. ( 이런 방식의 엘리먼트 구문을, “자체 닫기”라고 일컫는다 )




The two forms above produce identical results in an XML parser.
XML의 구문 분석기에서, 위의 두 가지 형태는 모두 똑같은 결과가 나온다.


Note: Empty elements do not have any content, but they can have attributes!
콘텐츠가 들어있지 않은 빈 엘리먼트에도 속성을 지정할 수 있다.


XML Naming Rules

XML에서 이름을 정할 때의 규칙들


XML elements must follow these naming rules:
XML의 엘리먼트는 다음과 같은 규칙에 따라 이름을 정해야 한다.


  • Element names are case-sensitive
    대소문자를 정확히 구분지어서 이름을 짓는다.

  • Element names must start with a letter or underscore
    첫글자는 문자나 밑줄( _ )이어야 한다.

  • Element names cannot start with the letters xml (or XML, or Xml, etc)
    xml이나 XML, Xml 등등, xml이라는 단어로 시작해서는 안된다.

  • Element names can contain letters, digits, hyphens, underscores, and periods
    이름에는 문자, 숫자, 하이픈( - ), 밑줄, 마침표가 들어갈 수 있다.

  • Element names cannot contain spaces
    이름에 빈칸이 들어갈 수 없다.

Any name can be used, no words are reserved (except xml).
“xml”이란 단어를 제외하고는 어떤 이름도 쓸 수 있으며, 예약어는 없다.


Best Naming Practices

이름을 정하는 가장 좋은 방법들


Create descriptive names, like this: <person>, <firstname>, <lastname>
(관련된 내용을) 묘사하는 이름을 만들어라.


Create short and simple names, like this: <book_title> not like this: <the_title_of_the_book>
길지 않은, 짧고 단순한 이름을 만들어라.


Avoid "-". If you name something "first-name", some software may think you want to subtract "name" from "first".

하이픈을 피하라. 이름을 “first-name”이라 하면, 어떤 프로그램은 “first”에서 “name”을 빼버리길 바란다고 여길 것이다.
하이픈은 사용하지 말아라. 어떤 프로그램들은 하이픈을 뺄셈 기호로 인식해버릴 수 있다.


Avoid ".". If you name something "first.name", some software may think that "name" is a property of the object "first".
마침표를 피하라. “first.name”이라 할 경우, “first”라는 객체의 속성이 “name”이라고 인식할 수도 있다.


Avoid ":". Colons are reserved for namespaces (more later).
콜론을 피하라. 콜론은 namespace를 위한 예약어이다.


Non-English letters like éòá are perfectly legal in XML,
but watch out for problems if your software doesn't support them.

éòá와 같은, 영어가 아닌 문자들도 XML에서는 전적으로 허용된다.
하지만 당신이 가지고 있는 소프트웨어가 이것을 지원하지 않는다면, 문제가 발생할 수 있다.


Naming Styles


There are no naming styles defined for XML elements. But here are some commonly used:
XML 엘리먼트의 이름을 짓는 스타일에 대해서 정해진 사항은 없으나, 일반적으로 다음과 같이 한다.


스타일 예문 설명
  소문자   <firstname>   이름 전체를 소문자로 한다
  대문자   <FIRSTNAME>   이름 전체를 대문자로 한다
  밑줄   <first_name>   단어와 단어 사이를 밑줄로 구분짓는다
  Pascal case   <FirstName>   각 단어의 첫글자를 대문자로 한다
  Camel case   <firstName>   첫번째 단어 외의, 나머지 단어의 첫글자를 대문자로 한다

If you choose a naming style, it is good to be consistent!
이름 짓는 스타일을 선택할 경우, 일관성을 유지하는 게 좋다.


XML documents often have a corresponding database.
A good practice is to use the naming rules of your database for the elements in the XML documents.


XML 문서에는 특정 자료와 서로 일치하는 데이터베이스가 들어가기도 한다.
자신의 데이터베이스에서 사용하는 방법과 똑같은 방식으로,
XML 엘리먼트의 이름을 정하는 습관을 들이는 게 좋다.


XML Elements are Extensible

XML 엘리먼트는 확장성이 있다. (내용물을 추가할 수 있다)


XML elements can be extended to carry more information.

더 많은 정보를 가져와 담기 위해서, XML 엘리먼트는 확장될 수 있다.


Look at the following XML example:
다음과 같은 XML 예문을 한번 살펴보자.

 
<note>
    <to>Tove</to>
    <from>Jani</from>
    <article>Don't forget me this weekend!</article>
</note>
 

Let's imagine that we created an application
that extracted the <to>, <from>, and <article> elements from the XML document to produce this output:


XML 문서에서 <to>와 <from>, <article> 엘리먼트들을 뽑아와서 아래의 출력 내용을 만드는,
응용프로그램을 만들었다고 가정해보자.

 
MESSAGE 

To: Tove
From: Jani

Don't forget me this weekend!
 

Imagine that the author of the XML document added some extra information to it:
XML 문서를 만든 사람이 추가 정보를 덧붙였다고 생각해보자.

 
<note>
    <date>2008-01-10</date>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <article>Don't forget me this weekend!</article>
</note>
 

Should the application break or crash?
응용프로그램이 충돌하거나 깨지게 될까?


No. The application should still be able to find the <to>, <from>, and <article> elements in the XML document
and produce the same output.

그렇지 않다. 응용프로그램은 여전히, XML 문서에서 <to>와 <from>, <article> 엘리먼트들을 찾아와서,
똑같이 출력을 할 것이다.


One of the beauties of XML, is that it can be extended without breaking applications.
XML이 가진, 멋진 장점들 중 하나가, 응용프로그램의 충돌 없이 내용을 늘릴 수 있다는 것이다.




이 글이 도움이 되셨나요? *^^*

'XML > w3schools' 카테고리의 다른 글

[ XML ] 6. XML Namespaces  (0) 2015.06.22
[ XML ] 5. XML 엘리먼트의 속성  (0) 2015.06.22
[ XML ] 3. XML 문서에서의 문법  (0) 2015.06.20
[ XML ] 2. XML의 트리 구조  (0) 2015.06.20
[ XML ] 1. XML 문서의 예문  (0) 2015.06.20