컴퓨터 공부/번역

5. XML 엘레먼트

려리군 2009. 5. 13. 01:37

XML Elements
XML 엘레먼트


An XML document contains XML Elements.
XML 문서는 XML 엘레먼트를 포함한다.


What is an XML Element?
XML 엘레먼트는 무엇인가?

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, simple text or a mixture of both. Elements can also have attributes.
엘레먼트는 간단한 텍스트나 혼합된 형태로 다른 엘레먼트를 포함할 수 있다. 엘레먼트는 또한 속성들을 가진다.


<bookstore>
<book category="CHILDREN">
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title>Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>


In the example above, <bookstore> and <book> have element contents, because they contain other elements. <author> has text content because it contains text.
위의 예제에서 <bookstore(책가계)>와 <book(책)>은 다른 엘레먼트들을 포함하기 때문에
엘레먼트 내용을 가진다. <author(저자)>는 텍스트를 포함하기 때문에 텍스트 내용을 가진다.

In the example above only <book> has an attribute (category="CHILDREN").
위의 예제에서 <book(책)>은 속성(category(분류)="CHILDREN(어린이)")을 가진다.


XML Naming Rules
XML 명명 규칙

XML elements must follow these naming rules:
XML 엘레먼트는 다음과 같은 명명 규칙을 따라야 한다.

  • Names can contain letters, numbers, and other characters
  • 이름은 문자, 숫자, 다른 문자들을 포함할 수 있다.
  • Names cannot start with a number or punctuation character
  • 이름은 숫자나 마침표로 시작할 수 없다.
  • Names cannot start with the letters xml (or XML, or Xml, etc)
  • 이름은 (XML, Xml등과 같은)xml로 시작할 수 없다.
  • Names cannot contain spaces
  • 이름은 공백을 포함할 수 없다.

Any name can be used, no words are reserved.
어떠한 이름이든 사용될 수 있고 예약된 단어는 없다.


Best Naming Practices
가장 좋은 명명 실습

Make names descriptive. Names with an underscore separator are nice: <first_name>, <last_name>.
이름을 설명하기 좋게 지어라. 참고로 <first_name>, <last_name> 같은 _(underscope) 구분자를 포함한 이름은 좋다.

Names should be short and simple, like this: <book_title> not like this: <the_title_of_the_book>.
이름은 <the_title_of_the_book> 같지 않고 <book_title> 같이 짧고 간단해야 한다.

Avoid "-" characters. If you name something "first-name", some software may think you want to subtract name from first.
"-" 문자를 피해라. 당신이 "first-name"라고 이름을 지었다면 몇몇 소프트웨어는 first로부터 name을 빼는 것을 원한다고 생각할 수 있다.

Avoid "." characters. If you name something "first.name," some software may think that "name" is a property of the object "first."
"." 문자를 피해라. 당신이 "first.name,"라고 이름을 지었다면 몇몇 소프트웨어는 first의 객체 속성이 name이라고 생각할 수 있다.

Avoid ":" characters. Colons are reserved to be used for something called namespaces (more later).
":" 문자를 피해라. 콜론은 네임스페이스라고 불리는 것(나중에 나옴)으로 사용하기 위해 예약되어 있다.

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 문서에서 엘레먼트를 위한 당신의 데이터베이스 명명 규칙을 사용하는 것이다.

Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software vendor doesn't support them.
éòá같은 영어가 아닌 문자는 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>
<body>Don't forget me this weekend!</body>
</note>


Let's imagine that we created an application that extracted the <to>, <from>, and <body> elements from the XML document to produce this output:
우리는 XML문서로부터 다음 출력을 생성하기 위해 <to>, <from>, and <body> 요소들을 추출하는 응용프로그램을 만들었다고 가정하자.


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>
<body>Don't forget me this weekend!</body>
</note>


Should the application break or crash?
응용프로그램은 깨지거나 충돌을 일으킬까?

No. The application should still be able to find the <to>, <from>, and <body> elements in the XML document and produce the same output.
아니다. 응용프로그램은 같은 출력을 생성하고 XML 문서에서 <to>, <from>, and <body> 엘레먼트들을 찾는 것이 가능하다.

One of the beauties of XML, is that it can often be extended without breaking applications.
XML의 아름다움은 응용프로그램을 깨지 않고 확장 가능하다는 점이다.


Reference : http://www.w3schools.com/xml/xml_elements.asp

'컴퓨터 공부 > 번역' 카테고리의 다른 글

7. XML 검증  (0) 2009.05.13
6. XML 속성  (0) 2009.05.13
4. XML 구문 규칙  (0) 2009.05.13
3. XML 트리  (0) 2009.05.12
2. 어떻게 XML이 사용될 수 있을까?  (0) 2009.05.12