1 / 26

DOM(core) Level 1

Chap.1. DOM(core) Level 1. SungShin Women’s Univ. DBS & MIPS Lab. limjm@cs.sungshin.ac.kr Lim, Jum Mee. Contents. 1. Overview 2. IDL 3. The DOM Structure Model 4. Memory Management 5. Naming Conventions 6. Inheritance vs. Flattened Views of the API

mercer
Download Presentation

DOM(core) Level 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chap.1 DOM(core) Level 1 SungShin Women’s Univ. DBS & MIPS Lab. limjm@cs.sungshin.ac.kr Lim, Jum Mee

  2. Contents • 1. Overview • 2. IDL • 3. The DOM Structure Model • 4. Memory Management • 5. Naming Conventions • 6. Inheritance vs. Flattened Views of the API • 7. The DOMString type & UTF 8/16 • 8. Case Sensitivity in the DOM • 9. Fundamental Interfaces 10. Extended Interfaces (1) DOMException (2) DOMImplementation (3) DocumentFragment (4) Document (5) Node (6) NodeList (7) NamedNodeMap (8) CharacterDataAttr (9) Element (10)Text (11)Comment (1) CDATASection (2) DocumentType (3) Notation (4) Entity (5) EntityReference (6) ProcessingInstruction DBS & MIPS Lab.

  3. 1.1 Overview • 문서 객체들을 접근하고 조작하기 위한 오브젝트들과 인터페이스들의 최소한의 집합을 정의 Scripts ThinClient HTML MiddleTier Web Server / App Server XSL, XQL DOM XML BackEnd DBS & MIPS Lab.

  4. IDL (계속) • Interface Definition Language • Interface Declaration • 분산 애플리케이션에서 객체가 제공하는 기능들을 기술 • 클라이언트가 네트워크상의 객체를 액세스하기 위해 필요한 모든 정보를 제공 • 인터페이스에 속한 속성 값과 연산들을 규정 • 각 연산의 매개변수값을 정의 • 기저(base) 인터페이스로부터 상속가능(다중상속, 간접상속) • Operation Declaration • 클라이언트가 구현객체의 기능에 액세스하기 위해 사용하는 함수(또는 메소드)의 형식(동기적) • 파라미터 전달 모드 • in : 메소드를 호출하는 클라이언트로부터 구현 객체로의 파라미터 전달 • out : 호출된 구현 객체로부터 클라이언트에게 파라미터 전달 • inout: 양방향으로 파라미터 전달 • 단방향(OneWay) Operation • 클라이언트가 호출한 연산의 결과를 기다리지 않아도 되는 경우, 기다리지 않고 수행을 계속하는 것. • 다른 일반적인 연산 문장보다 먼저 선언되어야 함. • 컨텍스트(Context) • 구현 객체의 특정 오퍼레이션에 영향을 줄 수 있는 클라이언트 환경요소와 관련된 리스트 interface인터페이스명{ 정의선언, 형선언, 예외선언, 속성선언, 오퍼레이션선언…. }; DBS & MIPS Lab.

  5. IDL (계속) • IDL Data Type • 기본타입 • 정수형(long, unsigned long, short, unsigned short) • 부동소수점형(float, double) • 문자형(char) : ISO Latin-1(8859.1)의 문자. 8비트 • 부울리언형(boolean) • 옥테트형(octet) : 전송중에 변환되지 않는 8비트 데이터 • any형(any) : 임의의 데이타형(void in C, C++) • 구조체타입 • structure, union, enumeration • 탬플릿타입 • sequencce(일차원배열), string(8비트 문자로 이루어지는 문자열) • Array • - 배열의 크기가 고정, 다차원배열 • Constant • const <type> <name> = <expressiong> • typedef • 기본적유형, 구조체/템플릿 유형에 이름을 부여하는 방법 • Comment • //(한줄주석), /* … */ (여러줄주석) DBS & MIPS Lab.

  6. IDL • Exception (예외처리) • 오퍼레이션 호출이 실패했을 경우, 클라이언트로 예외가 반환. • 종류 • 표준예외:시스템이 미리 정한 예외 • 사용자정의예외:어플리케이션 개발자가 예외정보의 구조체를 정의하는 예외(raises) • Module Declaration • 인터페이스나 오퍼레이션 등의 이름의 범위를 계층화하기 위해 모듈선언을 사용. • 모듈내에서 적절하게 IDL 선언들에 대한 범위를 설정함으로서 다른 모듈에서 사용된 식별자들과 충돌이 발생하는 것을 피할 수 있게 함. • 어떤 모듈에서 사용된 식별자들을 외부에서 사용하고자 할때는 “::”(이름 해결 연산자)사용 • Attribute • 클라이언트가 특정 변수에 어떤 값을 검색하거나 설정할때 손쉽게 IDL로 표현할 목적으로 고안. • 실제 특정 언어로 변환하며 _get과 _set의 두개의 오퍼레이션을 생성 • readonly를 사용하면, _get오퍼레이션만을 생성 DBS & MIPS Lab.

  7. 1.1.1The DOM Structure Model • Document -- Element (maximum of one), ProcessingInstruction, Comment, DocumentType • DocumentFragment -- Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference • DocumentType -- no children • EntityReference -- Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference • Element -- Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference • Attr -- Text, EntityReference • ProcessingInstruction -- no children • Comment -- no children • Text -- no children • CDATASection -- no children • Entity -- Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference • Notation -- no children • NodeList -- handle ordered lists of Nodes(children of a Node) • NamedNodeMap -- handle unordered sets of Nodes DBS & MIPS Lab.

  8. 1.1.2Memory Management • DOM API는 자신의 자료구조를 가진 legacy 응용의 top에 얇은 베티어판을 깐것처럼 구현됨. • 객체지향 디자인에서, 다양한 인터페이스를 구현하는 객체들의 인스탄스들을 생성하는 factory methods를 정의. • DOM Level 1에서, 어떤 인터페이스 “X”를 구현하는 객체들은 Document 인터페이스상의 “createX()”에 의해 생성. • DOMImplementation/Document객체들의 생성: bootstrapping • cf) 다른 객체들의 생성: Create methods • Core DOM API는 다양한 분야의 언어와 호환성이 있게 디자인. • Memory 관리 methods가 필요하지 않음. • > 다른 언어들과 binding할 때, 필요. DBS & MIPS Lab.

  9. 1.1.3 Naming Conventions • General: short, informative, internally consistent, familiar to users • OMG IDL & ECMAScript: long, quite descriptive • WG은 다양한 용어들의 사용에서 내부적으로 일관성을 가지려고 시도. • remove: 메소드가 구조 모델을 변화시킬때 • delete: 메소드가 구조모델에서 무언가를 제거할때 DBS & MIPS Lab.

  10. 1.1.4 Inheritance vs Flattened Views of the API • Two somewhat different sets of interface • object oriented approach: hierarchy of inheritance • simplified view:모든 조작이 COM 환경에서 변환을 요구하거나, 질의 인터페이스를 호출하는 것 없이 Node 인터페이스에 의해 수행되어 지게 하는 관점. • WG: • primary view of the API • : inheritance approach • users may employ • : full set of functionality on Node DBS & MIPS Lab.

  11. 1.1.5 The DOMString type • DOMString = 16비트의 크기를 가진 일차원 배열 • 응용프로그램은 UTF-16을 사용하여 DOMString을 인코딩해야만 함. • 문서 객체 집합은 UCS(Universal Character Set)-4에 기초. Typedef sequence<unsigned short> DOMString • UTF-16(UNICODE 문자세트) • 국제표준문자세트 • ISO 10646 UCS-2와 거의 동일 • 장점: • - 통합문자세트 및 인코딩 • - 다양한 기존문자세트및 인코딩 처리 • - 효율성과 편리성 • 단점: • - 기존 아스키 문자 세트와 충돌 • - 아스키문자가 2바이트로 표현되므로, • 기존 아스키 파일의 크기가 2배로 늘어남. • 적절한 사용법: • - 프로그램 내부 용도로만 사용. • (프로그램 내부 및 프로그램만이 이해하는 • 특정화일만 Unicode인코딩으로 표현). • UTF-8 • (Universal Character Set Transformation Format, 8bit) • ISO 10646 UCS-4 • 장점: • - 정보의 손실없이 유니코드와변환된다. • - 아스키 기반 환경과의 호환성 • - 범용성 • 단점: • - 한글 및 한자는 3바이트로 표현 • - 아직 UTF-8 인코딩을 지원하는 OS,DBMS, • 프로그램부족 • 적절한 사용법: • - 일반사용자가 직접다루는 파일 혹은 자료 전달에는 • 아스키문자와 충돌하지 않는 문자세트로 표현 DBS & MIPS Lab.

  12. 1.1.6 Case sensitivity in the DOM • DOM은 스트링 일치를 의미하는 많은 인터페이스들을 가짐. • Element: HTML(대문자), XML(case sensitive) • 스트링 일치는 DOMString의 16bit 값을 가진다는 문자 코드 원칙에 의해 문자 코드상에서 발생한다. • -> DOM은 DOM 구조가 생성되기 전에, 프로세서에서 어떤 정규화가 일어날것이라고 가정한다. • W3C 118N working group: 정규화가 DOM을 구현하는 응용에 필요한 것인지를 정확하게 정의하는 작업이 진행중. DBS & MIPS Lab.

  13. 1.2 Fundamental Interface (계속) • Exception DOMException exception DOMException { unsigned short code; }; // ExceptionCode const unsigned short INDEX_SIZE_ERR = 1; const unsigned short DOMSTRING_SIZE_ERR = 2; const unsigned short HIERARCHY_REQUEST_ERR = 3; const unsigned short WRONG_DOCUMENT_ERR = 4; const unsigned short INVALID_CHARACTER_ERR = 5; const unsigned short NO_DATA_ALLOWED_ERR = 6; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; const unsigned short NOT_FOUND_ERR = 8; const unsigned short NOT_SUPPORTED_ERR = 9; const unsigned short INUSE_ATTRIBUTE_ERR = 10; DBS & MIPS Lab.

  14. 1.2 Fundamental Interface (계속) • DOMImplementation • DOM의 어떤 특수한 인스탄스에 독립적인 오퍼레이션들을 수행하기위한 몇 개의 메소드를 제공. • Level 1은 문서 인스탄스를 생성하는 방법을 규정하고 있지 않음. • -> 문서생성은 구현에서의 특정한 오퍼레이션. • - hasFeature: DOM 구현이 구체적인 특징을 구현하는 지를 테스트 • DocumentFragment • “lightweight” or “minimal”문서 객체 • 다양한 오퍼레이션(예, 다른 노드의 children으로 노드를 삽입)에 용이. interface DOMImplementation { boolean hasFeature(in DOMString feature, in DOMString version);}; DBS & MIPS Lab.

  15. 1.2 Fundamental Interface (계속) • Document(1) • 전체 HTML 이나 XML 문서를 표현한다. • 개념적으로 문서트리의 루트이고 문서의 데이터에 대한 우선적 접근을 제공한다. interface Document : Node { readonly attribute DocumentType doctype; readonly attribute DOMImplementation implementation; readonly attribute Element documentElement; Element createElement(in DOMString tagName) raises(DOMException); DocumentFragment createDocumentFragment(); Text createTextNode(in DOMString data); Comment createComment(in DOMString data); CDATASection createCDATASection(in DOMString data) raises(DOMException); ProcessingInstruction createProcessingInstruction(in DOMString target, in DOMString data) raises(DOMException); Attr createAttribute(in DOMString name) raises(DOMException); EntityReference createEntityReference(in DOMString name) raises(DOMException); NodeList getElementsByTagName(in DOMString tagname); }; DBS & MIPS Lab.

  16. 1.2 Fundamental Interface (계속) • Document(2) • Attributes • doctype • implementation • documentElement • Methods • createElement • createDocument • createDocumentFragment • createTextNode • createComment • createCDATASection • createProcessingInstruction • crateAttribute • createEntityReference • getElementByTagName DBS & MIPS Lab.

  17. 1.2 Fundamental Interface (계속) • Node interface Node { // NodeType const unsigned short ELEMENT_NODE = 1; const unsigned short ATTRIBUTE_NODE = 2; const unsigned short TEXT_NODE = 3; const unsigned short CDATA_SECTION_NODE = 4; const unsigned short ENTITY_REFERENCE_NODE = 5; const unsigned short ENTITY_NODE = 6; const unsigned short PROCESSING_INSTRUCTION_NODE = 7; const unsigned short COMMENT_NODE = 8; const unsigned short DOCUMENT_NODE = 9; const unsigned short DOCUMENT_TYPE_NODE = 10; const unsigned short DOCUMENT_FRAGMENT_NODE = 11; const unsigned short NOTATION_NODE = 12; readonly attribute DOMString nodeName; attribute DOMString nodeValue; readonly attribute unsigned short nodeType; readonly attribute Node parentNode; readonly attribute NodeList childNodes; readonly attribute Node firstChild; readonly attribute Node lastChild; readonly attribute Node previousSibling; readonly attribute Node nextSibling; readonly attribute NamedNodeMap attributes; readonly attribute Document ownerDocument; Node insertBefore(in Node newChild, in Node refChild) raises(DOMException); Node replaceChild(in Node newChild, in Node oldChild) raises(DOMException); Node removeChild(in Node oldChild) raises(DOMException); Node appendChild(in Node newChild) raises(DOMException); boolean hasChildNodes(); Node cloneNode(in boolean deep);}; DBS & MIPS Lab.

  18. 1.2 Fundamental Interface (계속) • NodeList • 어떻게 이 집합들이 구현되는지 정의하거나 제한없이 노드들의 순서화된 집합들의 추상화를 제공 • NamedNodeMap • 이름에 의해 접근할 수 있는 노드들의 집합들을 표현하는데 사용 interface NodeList { Node item(in unsigned long index); readonly attribute unsigned long length; }; interface NamedNodeMap{ Node getNamedItem(in DOMString name); Node setNamedItem(in Node arg) raises(DOMException); Node removeNamedItem(in DOMString name) raises(DOMException); Node item(in unsigned long index); readonly attribute unsigned long length; }; DBS & MIPS Lab.

  19. 1.2 Fundamental Interface (계속) • CharacterData • Methods • substringData • appendData • insertData • deleteData • replaceData interface CharacterData : Node { attribute DOMString data; readonly attribute unsigned long length; DOMString substringData(in unsigned long offset, in unsigned long count) raises(DOMException); void appendData(in DOMString arg) raises(DOMException); void insertData(in unsigned long offset, in DOMString arg) raises(DOMException); void deleteData(in unsigned long offset, in unsigned long count) raises(DOMException); void replaceData(in unsigned long offset, in unsigned long count, in DOMString arg) raises(DOMException); }; DBS & MIPS Lab.

  20. 1.2 Fundamental Interface (계속) • Attr • Attributes • name • specified • REQUIRED • : attribute가 문서에서 할당된 값을 가지고 있다면 specified는 true • : 값은 할당된 값. • FIXED • : attribute가 문서에서 할당된 값을 가지고 있지 않고, DTD에서 기본 값을 가지고 있다면, specified는 false • : 값은 DTD에 있는 기본 값. • IMPLIED • : attribute가 문서에서 할당된 값을 가지고 있지 않고, DTD에서 #IMPLIED의 값을 가지고 있다면, attribute는 문서의 구조 모델에서 • 나타나지 않는다. • value interface Attr : Node { readonly attribute DOMString name; readonly attribute boolean specified; attribute DOMString value; }; DBS & MIPS Lab.

  21. 1.2 Fundamental Interface (계속) • Element • Methods • getAttribute(이름에 의해 속성 값을 검색), setAttribute(새로운 속성을 추가) • removeAttribute(이름에 의해 속성 제거) • getAttributeNode(이름에 의해 Attr Node 검색), setAttributeNode(새로운 속성을 추가), removeAttributeNode(특정한 속성을 제거) • getElementsByTagName(지정된 tag이름의 모든 자손 엘리먼트들의 NodeList를 반환) • normalize interface Element : Node { readonly attribute DOMString tagName; DOMString getAttribute(in DOMString name); void setAttribute(in DOMString name, in DOMString value) raises(DOMException); void removeAttribute(in DOMString name) raises(DOMException); Attr getAttributeNode(in DOMString name); Attr setAttributeNode(in Attr newAttr) raises(DOMException); Attr removeAttributeNode(in Attr oldAttr) raises(DOMException); NodeList getElementsByTagName(in DOMString name); void normalize(); }; DBS & MIPS Lab.

  22. 1.2 Fundamental Interface • Text • Methods • splitText • Comment • ‘<!--’….. ‘-->’ interface Text : CharacterData { Text splitText(in unsigned long offset) raises(DOMException); }; interface Comment : CharacterData { }; DBS & MIPS Lab.

  23. 1.3 Extended Interface (계속) • CDATASection • DocumentType • Attributes • name • entities • notations • Level1에서는 DocumentType 노드들의 수정을 지원하지 않음. interface CDATASection : Text { }; interface DocumentType : Node { readonly attribute DOMString name; readonly attribute NamedNodeMap entities; readonly attribute NamedNodeMap notations; }; DBS & MIPS Lab.

  24. 1.3 Extended Interface (계속) • Notation • Level1에서는 Notation 노드들의 수정을 지원하지 않음. • Entity interface Notation : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; }; interface Entity : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; readonly attribute DOMString notationName; }; DBS & MIPS Lab.

  25. 1.3 Extended Interface • EntityReference • ProcessingInstruction • Attributes • target • data interface EntityReference : Node { }; interface ProcessingInstruction : Node { readonly attribute DOMString target; attribute DOMString data; // raises(DOMException) on setting }; DBS & MIPS Lab.

  26. 참고사이트 및 문헌 • DOM: • http://www.w3.org/TR/REC-DOM-Level-1 • http://xml.css.xo.kr/frame.html • http://webreview.com/wr/pub/97/11/14/feature/concepts.html • http://webreview.com/97/11/14/index.html • http://msdn.microsoft.com/xml/reference/xmldom/start.asp • XML: • http://www.w3.org/TR/1998/REC-xml-19980210 • IDL Syntax & Semantics: • http://rd.runnet.ru/CORBA/idlsyn.htm • http://cs.chungnam.ac.kr/~jhpark/http/idl_is.html • http://elec.sch.ac.kr/islab/info/corba/omg_idl.html • http://queen.sungshin.ac.kr/~limjm/RESEARCH/DOM/IDL • UTF-8/16: • http://calab.kaist.ac.kr/~dtkim/java/encoding.htm • http://www.klipl.com/info/hgcode/hgcd_rpt.html • http://queen.sungshin.ac.kr/~limjm/RESEARCH/XML/seminar/spec12/utf-8.html DBS & MIPS Lab.

More Related