[xml] 웹 서비스 응답에서 text / xml과 application / xml의 차이점은 무엇입니까?

이 차이에 대한 일반적인 질문의 더 text/xml하고 application/xml. 나는 웹 서비스 (REST-Jersey)를 작성하는 데 상당히 익숙합니다. 나는 application/xml그것이 배우기 위해 사용했던 대부분의 튜토리얼 / 코드 예제에서 나타나는 것이기 때문에 생산 해 왔지만 최근에 text/xml무엇이 다른지, 언제 그것을 사용할 것인지 궁금해하고 있었 application/xml습니까?



답변

이것은 오래된 질문이지만 RFC3023을 폐기하는 RFC 7303 에서 자주 방문하고 명확한 권장 사항을 사용할 수 있습니다 . 간단히 말해서 (섹션 9.2) :

The registration information for text/xml is in all respects the same
as that given for application/xml above (Section 9.1), except that
the "Type name" is "text".


답변

RFC ( 3023 )의 섹션 3, XML 매체 유형에서 :

일반 사용자 XML 문서 (처리되지 않은 소스 XML 문서 )를 읽을 수있는 경우 text / xml 이 application / xml보다 선호됩니다. text / xml을 명시 적으로 지원하지 않는 MIME 사용자 에이전트 (및 웹 사용자 에이전트)는 XML MIME 엔터티를 일반 텍스트로 표시하여이를 텍스트 / 일반으로 처리합니다.

일반 사용자 XML MIME 엔터티 를 읽을 수없는 경우 Application / xml 이 바람직 합니다.

(강조 광산)


답변

이 기사 에 따르면 application / xml이 선호됩니다.


편집하다

나는 기사에 약간의 후속 조치를 취했다.

저자는 다음과 같이 XML 처리 명령에서 선언 된 인코딩이라고 주장합니다.

<?xml version="1.0" encoding="UTF-8"?>

text/xml용지 종류를 사용하는 경우 무시할 수 있습니다 .

RFC 2046text/*MIME 유형 패밀리 사양 의 정의 , 특히 다음 조각과 같은 논문을 지원합니다 .

4.1.2.  Charset Parameter

   A critical parameter that may be specified in the Content-Type field
   for "text/plain" data is the character set.  This is specified with a
   "charset" parameter, as in:

     Content-type: text/plain; charset=iso-8859-1

   Unlike some other parameter values, the values of the charset
   parameter are NOT case sensitive.  The default character set, which
   must be assumed in the absence of a charset parameter, is US-ASCII.

   The specification for any future subtypes of "text" must specify
   whether or not they will also utilize a "charset" parameter, and may
   possibly restrict its values as well.  For other subtypes of "text"
   than "text/plain", the semantics of the "charset" parameter should be
   defined to be identical to those specified here for "text/plain",
   i.e., the body consists entirely of characters in the given charset.
   In particular, definers of future "text" subtypes should pay close
   attention to the implications of multioctet character sets for their
   subtype definitions.

그들에 따르면, application/xmlMIME 타입을 사용할 때 이러한 어려움을 피할 수 있습니다 . 그것이 사실이든 아니든, 나는 피하지 않을 것 text/xml입니다. IMHO, 인간 가독성 (비가 독성)의 의미를 따르는 것이 가장 좋으며 항상 문자 세트를 지정해야합니다.


답변

application/xml하여 볼 svn같은 이진 반면 형식 text/xml으로 텍스트 DIFF가 표시 될 수있는 파일.


답변