9 주 실습강의 xml visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )
TRANSCRIPT
![Page 1: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/1.jpg)
99 주 실습강의주 실습강의XML Visualization(1)XML Visualization(1)
2009. 1 학기 , 소프트웨어 설계 및 실험 (Ⅰ)
![Page 2: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/2.jpg)
Artificial Intelligence Laboratory
실습목표
![Page 3: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/3.jpg)
Artificial Intelligence Laboratory
프로그램에서 XML 문서 이용 방법
DOM- Document Object Model- XML 문서를 Object의 개념으로 생각- 문서를 한번에 읽어서 처리 ( 수정 , 삭제 용이 )
SAX- Simple API for XML- 이벤트 중심의 방법- 문서를 순차적으로 읽음 ( 속도 , 메모리 측면에서 효율적 )- 문서 전체 구조정보를 가지지 않음
![Page 4: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/4.jpg)
Artificial Intelligence Laboratory
XML DOM (Document Object Model)
![Page 5: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/5.jpg)
Artificial Intelligence Laboratory
XML SAX(Simple API for XML)
![Page 6: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/6.jpg)
Artificial Intelligence Laboratory
DOM VS SAX
![Page 7: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/7.jpg)
Artificial Intelligence Laboratory
XML Parser
Xerces- http://xerces.apache.org/xerces-c/- 오픈 소스 XML 파서- IBM에서 개발 (xml4c)- C++, Java, Perl 지원- 현재 Apache에서 개발 / 관리- 현재 버전 Xerces-C++ 3.0.1
![Page 8: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/8.jpg)
Artificial Intelligence Laboratory
Xerces 설치
Xerces Download- http://xerces.apache.org/xerces-c/download.cgi- xerces-c-3.0.1.zip (for windows)- 압축해제- 솔루션 실행
~\xerces-c-3.0.1\projects\Win32\VC9\xerces-all\Xerces-all.sin
- Build (빌드 -> 솔루션빌드 단축키 F6) ~\xerces-c-3.0.1\Build\Win32\VC9\Debug\xerces-c_3_0D.dll 생성
![Page 9: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/9.jpg)
Artificial Intelligence Laboratory
Xerces 사용법
새 프로젝트 생성 ( VC++ Win32 Console Application)- 추가 옵션에서 빈 프로젝트 체크
프로젝트에서 main.cpp 추가 프로젝트 속성 설정
- C/C++ -> 일반 -> 추가 포함 디렉터리 ~\xerces-c-3.0.1\src 추가
- 링커 -> 일반 -> 추가 라이브러리 디렉터리 ~\xerces-c-3.0.1\Build\Win32\VC9\Debug 추가
- ~\xerces-c-3.0.1\Build\Win32\VC9\Debug\xerces-c_3_0D.dll
프로젝트 폴더에 복사- 링커 -> 입력 -> 추가종속성
Xerces-c_3D.lib 추가
![Page 10: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/10.jpg)
Artificial Intelligence Laboratory
Xerces 사용법
실행 테스트#include <xercesc/sax2/SAX2XMLReader.hpp>#include <xercesc/sax2/XMLReaderFactory.hpp>
int main(int argc, char * argv){return 0;
}
![Page 11: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/11.jpg)
Artificial Intelligence Laboratory
XML Handler 생성
Handler Class 생성 클래스 뷰 -> 프로젝트 추가 -> 클래스
- C++ 클래스- 클래스 이름 설정 (ex SAXHandler)- 기본클래스 DefaultHandler
- “ 예” 클릭- #include <xercesc/sax2/DefaultHandler.hpp> 추가
DefaultHandler Interface
- #include <xercesc/sax2/Attributes.hpp> 추가- XECES_CPP_NAMESPACE_USE 추가
namespace
![Page 12: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/12.jpg)
Artificial Intelligence Laboratory
![Page 13: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/13.jpg)
Artificial Intelligence Laboratory
DefaultHandler- Handler Class의 기본 모델
- SAX Parser를 사용하기 위한 base class- DefaultHandler Class 를 상속하여 Interface함수를
재정의 하여 사용
![Page 14: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/14.jpg)
Artificial Intelligence Laboratory
DefaultHandler의 주요 메서드
http://xerces.apache.org/xerces-c/apiDocs-3/classDefaultHandler.html
virture void startDocument()virture void endDocument()virture void startElement(
const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
virture void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
virture characters(const XMLCh *const chars, const XMLSize_t length)
![Page 15: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/15.jpg)
Artificial Intelligence Laboratory
startDocument()함수 추가- 클래스 뷰 -> HanderClass 우클릭 -> 추가 -> 함수 추가
반환 형식 void 함수 이름 startDocument() 마침
- endDocument() 함수 추가
각각 문서의 시작과 끝에 자동으로 호출됨 .
![Page 16: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/16.jpg)
Artificial Intelligence Laboratory
Main 작성
![Page 17: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/17.jpg)
Artificial Intelligence Laboratory
Main
![Page 18: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/18.jpg)
Artificial Intelligence Laboratory
추가구현
<book genre="novel"><title>The Confidence Man</title>
</book>
OutputElementStart=bookAttributeQName=genreAttributeValue=novelElementStart=titleTextValue=The Confidence ManElementEnd=titleElementEnd=book
![Page 19: 9 주 실습강의 XML Visualization(1) 2009. 1 학기, 소프트웨어 설계 및 실험 ( Ⅰ )](https://reader030.vdocuments.mx/reader030/viewer/2022012312/56649f585503460f94c7e6a2/html5/thumbnails/19.jpg)
Artificial Intelligence Laboratory
추가구현
Element - XMLString::transcode(qname)
qname의 값 출력 . Attribute
- attribute.getLength()
Attribute 개수 .- attribute.getQName(index)
Attribute QName- attribute.getValue(index)
Attribute Value