XML 과 SQL Server 2000 에서 지원하는 XML 처리 방법 정 홍주 WebTime Feelanet.

Slides:



Advertisements
Similar presentations
2/23/05 CS Advanced Databases 1 XML Support in SQL Server 2000 Sriram Krishnan Kevin Menard.
Advertisements

CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
XML: Extensible Markup Language
Inside Data Access with SQLXML: Architecture Guide Rolandas Gricius MCT, MCSE, MCSD Adapted From.
XML Extensible Markup Language Standard supported by W3C (World Wide Web Consortium) HTML – End user oriented (presentation) XML – Application oriented.
XSL Concepts Lecture 7. XML Display Options What can XSL Transformations do? generation of constant text suppression of content moving text (e.g., exchanging.
Copyright 2000, Microsoft Corp. SQL Server 2000 XML Annotated Schemata Michael Rys Program Manager SQLServer XML Technologies Microsoft Corporation
1 Storing XML using Relational Model XML and data management By: Habiba Skalli For: Dr. Haddouti.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
CIS607, Fall 2005 Semantic Information Integration Article Name: Clio Grows Up: From Research Prototype to Industrial Tool Name: DH(Dong Hwi) kwak Date:
17 Apr 2002 XML Stylesheets Andy Clark. What Is It? Extensible Stylesheet Language (XSL) Language for document transformation – Transformation (XSLT)
SQL Server 2000 and XML Erik Veerman Consultant Intellinet Business Intelligence.
Viewing relational data as XML Using Microsoft SQL Server.
DAT304 Leveraging XML and HTTP with Sql Server Irwin Dolobowsky Program Manager Webdata Group.
19 – 21 MARCH 2006 Riyadh, Saudi Arabia. XML and Web Services support in SQL Server 2005 Michael Storey Xpertise Training Ltd (UK)
2.2 SQL Server 2005 的 XML 支援功能. Overview XML Enhancements in SQL Server 2005 The xml Data Type Using XQuery.
XML Fundementals XML vs.. HTML XML vs.. HTML XML Document (elements vs. attributes) XML Document (elements vs. attributes) XML and RDBMS XML and RDBMS.
Sheet 1XML Technology in E-Commerce 2001Lecture 6 XML Technology in E-Commerce Lecture 6 XPointer, XSLT.
Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 1 of 31 Objectives In this lesson, you will learn to: * Generate.
Using XML in SQL Server 2005 NameTitleCompany. XML Overview Business Opportunity The majority of all data transmitted electronically between organizations.
CSE3201/CSE4500 XPath. 2 XPath A locator for elements or attributes in an XML document. XPath expression gives direction.
XML in SQL Server Overview XML is a key part of any modern data environment It can be used to transmit data in a platform, application neutral form.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
CSE3201/CSE4500 Information Retrieval Systems
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
CIS 451: XSL Dr. Ralph Westfall February, Problems With XML no formatting capabilities contra formatting tags like, etc. in HTML CSS can be used.
IT420: Database Management and Organization XML 21 April 2006 Adina Crăiniceanu
WORKING WITH XSLT AND XPATH
Sofia, Bulgaria | 9-10 October Using XQuery to Query and Manipulate XML Data Stephen Forte CTO, Corzen Inc Microsoft Regional Director NY/NJ (USA) Stephen.
Company LOGO OODB and XML Database Management Systems – Fall 2012 Matthew Moccaro.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XML Part 2 Josh Steele CS 6704, Spring XML Part 2 XSL/XSLT –Structure Revisited –Definition –Example –Components XML’s Linking Languages XML’s Uses.
Transforming Documents „a how-to of transforming xml documents“ Lecture on Walter Kriha.
Lecture 11 XSL Transformations (part 1: Introduction)
DAT 379 XML Today And Tomorrow Mark Fussell Lead Program Manager Microsoft Corporation.
DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.
5/24/01 Leveraging SQL Server 2000 in ColdFusion Applications December 9, 2003 Chris Lomvardias SRA International
Module 18 Querying XML Data in SQL Server® 2008 R2.
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
Retrieving XML Data from SQL server.  Using the FOR XML Clause to Retrieve Data Retrieving Data in XML Format How SQL Server Generates XML Using the.
SQLXML 의 세부 기능 소개 정 홍주 WebTime Feelanet. 목차  Updategram  Differgram  Bulk Load  Using Mapping Schemas  URL 을 통한 HTTP Access  Optimizing SQLXML Performance.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000.
XML and Object Serialization. Structure of an XML Document Header Root Element Start Tags / End Tags Element Contents – Child Elements – Text – Both (mixed.
 XSL – Extensible Style Sheet Language  XSLT – XSL Transformations › Used to transform XML documents to other formats,like HTML or other XML documents.
Computing & Information Sciences Kansas State University Friday, 20 Oct 2006CIS 560: Database System Concepts Lecture 24 of 42 Friday, 20 October 2006.
Chapter 14 1 Chapter 14 Storing and Retrieving XML in SQL Server 2000 November 6, 2001 Sook-Kyo Kwon.
SQLXML XML Technology For SQL Server Brian Moore Developer and Platform Strategy Group Microsoft Corporation.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
DAT 405 Extreme SqlXml Irwin Dolobowsky Program Manager – SqlXml Microsoft Corporation.
Dev399 SQLXML: XML Views and Relational Data Irwin Dolobowsky Program Manager Webdata Group Microsoft Corporation.
Copyright 2002, Ronald Bourret, XML-DBMS Middleware for XML and databases Ronald Bourret O'Reilly Open.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
1 XSL Transformations (XSLT). 2 XSLT XSLT is a language for transforming XML documents into XHTML documents or to other XML documents. XSLT uses XPath.
XML and SQL Server Better friends than you thought Matt Hartman.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
Apache Cocoon – XML Publishing Framework 데이터베이스 연구실 박사 1 학기 이 세영.
DAT 400 Inside Data Access with SQLXML: Architecture Guide Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.
1 XSLT XSLT (extensible stylesheet language – transforms ) is another language to process XML documents. Originally intended as a presentation language:
XML: Extensible Markup Language
Unit 4 Representing Web Data: XML
Using XML in SQL Server and Azure SQL Database
Querying and Transforming XML Data
Database Processing with XML
ACG 4401 XSLT Extensible Stylesheet Language for Transformations
Chapter 7 Representing Web Data: XML
XML Data Introduction, Well-formed XML.
Presentation transcript:

XML 과 SQL Server 2000 에서 지원하는 XML 처리 방법 정 홍주 WebTime Feelanet

목차 .NET Framework  SQLXML  SQLXML 과 관련된 XML 기술  SQL Server 2000 에서의 XML 지원

.NET Framework Web Server 브라우저 World! ADO.NET / XML / XML Schema HTML, XML OS 데이터 저장소 HTTP Handler /ASP.NET ADO.NET.NET RMI / SOAP 컨텍스트 보안 트랜잭션 동시성 Serviced Component Managed Object COM+ Server CLR SOAP,XML

.NET vs. SQLXML .NET XML-Object Mapping Layer XML-Object Mapping Layer XML Serialization XML Serialization XML-Relation Mapping Layer XML-Relation Mapping Layer ADO.NET ADO.NET  SQLXML XML-Relation Mapping Layer XML-Relation Mapping Layer

XML vs Relational  Relational format : data storage 각 entity 의 instance 는 row 각 entity 의 instance 는 row 각 entity 의 property 는 column 각 entity 의 property 는 column Relationships 은 key field 를 기반으로 Relationships 은 key field 를 기반으로  XML : data exchange 각 entity 의 instance 는 element 각 entity 의 instance 는 element 각 entity 의 Properties 는 value, attribute, 또는 child element 각 entity 의 Properties 는 value, attribute, 또는 child element Relationships 은 계층적으로 묘사 Relationships 은 계층적으로 묘사

E-Commerce 시나리오 RetailerShipper Customer Supplier Purchase order Catalog Delivery request Extranet Web site Intranet Web site

SQLXML  RDB 의 구조적 데이터를 XML 로 변환  XML 을 RDB 의 구조적 데이터로 변환  XML-Relation Mapping Layer XML business document, e.g., purchase order RetailerSupplier

SQLXML Architecture IISISAPI ADO HTTP COM Annotated Schemas SQL Server SQLOLEDB ClientMiddle TierSQL Server Translation of: Updategrams Query templates XPath queries SQL executed: Open XML T-SQL Update Insert Delete Select…For XML Updategram Query request

SQLXML Architecture

SQLXML 과 관련된 XML 기술  XML Schema  XPath  XSLT

XML Schema  Schema 는 XML 문서의 규약을 동의 element, attribute – 데이터타입, 순서, 길이, 최대 / 최소값 element, attribute – 데이터타입, 순서, 길이, 최대 / 최소값 XML business document, e.g., purchase order RetailerSupplier Schema

"urn:nwtraders" XPath  XPath 는 W3C XML Path Language  XPath 를 이용 XML 문서를 네비게이션, 검색, 조작  XPath 는 DOM, XQuery, XSL, XSLT 과 같이 사용됨 <Plants xmlns="urn:nwtraders"> Clematis <Plants xmlns="urn:nwtraders"> Clematis "123" "Clematis" Root "urn:nwtraders" "comment " "proc-instr"

XPath  XPath 표준 navigation language  XML 계층구조로부터 XPath 쿼리로 노드를 리턴 모든 OrderDetail 요소들 모든 OrderDetail 요소들 ProductID 특성이 23 인 OrderDetail 요소들 ProductID 특성이 23 인 OrderDetail 요소들 Quantity 가 1 보다 큰 요소를 가진 OrderDetail 요소 Quantity 가 1 보다 큰 요소를 가진 OrderDetail 요소 Order/OrderDetail[Quantity > 1] Order/OrderDetail

XSLT  XSLT 는 W3C XSL Transformations language  XPath 와 같이 사용  XML vocabularies 와 포맷으로 변환하는데 사용 XML vocabulary 변환 XML 을 HTML 이나 text 로 변환 Lemon Lemon 3 Lemon 3 XML HTML

XSLT  XSL 스타일 시트를 적용시 XML 문서를 다른 포맷 (HTML) 으로 변환 XML 문서를 다른 포맷 (HTML) 으로 변환 XML 문서를 또 다른 포맷 (XML,WML) 으로 변환 XML 문서를 또 다른 포맷 (XML,WML) 으로 변환 XML XSL

XSLT & XPath <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:stylesheet version="1.0" xmlns:xsl=" 로트노트로 부터 employee name 을 리스트 XPath 루트노드 밑의 로 정렬

SQL Server 2000 에서의 XML 지원  SQL Server Data 를 XML 로 처리하는 방법  Transact-SQL  XML 을 이용한 SQL Server Data 변경

XML 을 처리하는 방법  System.Data  System.Xml  T-SQL  UpdateGram/Bulk Load  SOAP/WSDL  SQLOLEDB/SQLXMLOLEDB  Managed SQLXML Class  Biztalk  …,

Transact-SQL  SELECT... FOR XML 결과셋이 XML stream 으로 리턴 결과셋이 XML stream 으로 리턴 relational data 를 XML 로 검색 relational data 를 XML 로 검색  OpenXML XML stream 을 rowset 으로 리턴 XML stream 을 rowset 으로 리턴 XML data 를 relational tables 로 Insert XML data 를 relational tables 로 Insert

XML 을 이용한 SQL Server Data 변경  XML Updategrams 추가, 수정, 삭제시 XML document 을 사용 추가, 수정, 삭제시 XML document 을 사용  XML Bulk Loader Component COM component COM component XML data 의 bulk-load 시 XML data 의 bulk-load 시

FOR XML  FOR XML 구문  XML Document Fragments SELECT select_list FROM table_source WHERE search_condition FOR XML RAW | AUTO | EXPLICIT [, XMLDATA] [, ELEMENTS] [, BINARY BASE64] SELECT select_list FROM table_source WHERE search_condition FOR XML RAW | AUTO | EXPLICIT [, XMLDATA] [, ELEMENTS] [, BINARY BASE64]

SQL Server Generate ROWSET TDS/ Token XML SELECT … FROM … WHERE … FOR XML MODE SELECT … FROM … WHERE … FOR XML MODE Query processor ROWSET to XML

Using RAW Mode  각각의 레코드에 하나의 element 각 컬럼은 attibute 로 처리 각 컬럼은 attibute 로 처리 SELECT OrderID, OrderDate FROM Orders FOR XML RAW SELECT OrderID, OrderDate FROM Orders FOR XML RAW

Using AUTO Mode  테이블 이름이 element 의 이름 중첩을 지원, 컬럼은 attribute 로 처리 중첩을 지원, 컬럼은 attribute 로 처리 Alias 로 이름 변경 가능 Alias 로 이름 변경 가능 SELECT OrderID, OrderDate FROM Orders FOR XML AUTO SELECT OrderID, OrderDate FROM Orders FOR XML AUTO

ELEMENTS  컬럼은 child element 로 처리 SELECT OrderID, OrderDate FROM Orders FOR XML AUTO, ELEMENTS SELECT OrderID, OrderDate FROM Orders FOR XML AUTO, ELEMENTS /04/ /05/ /04/ /05/1996

예 ) Table Join SELECT OrderForm.OrderID, Item.ProductID Item.Quantity FROM Orders OrderForm JOIN [Order Details] Item ON OrderForm.OrderID = Item.OrderID ORDER BY OrderForm.OrderID FOR XML RAW SELECT OrderForm.OrderID, Item.ProductID Item.Quantity FROM Orders OrderForm JOIN [Order Details] Item ON OrderForm.OrderID = Item.OrderID ORDER BY OrderForm.OrderID FOR XML RAW SELECT OrderForm.OrderID, Item.ProductID Item.Quantity FROM Orders OrderForm JOIN [Order Details] Item ON OrderForm.OrderID = Item.OrderID ORDER BY OrderForm.OrderID FOR XML AUTO SELECT OrderForm.OrderID, Item.ProductID Item.Quantity FROM Orders OrderForm JOIN [Order Details] Item ON OrderForm.OrderID = Item.OrderID ORDER BY OrderForm.OrderID FOR XML AUTO

XMLDATA  XML-Data Reduced (XDR) Schema 로 리턴 SELECT OrderID, OrderDate FROM Orders FOR XML AUTO, XMLDATA SELECT OrderID, OrderDate FROM Orders FOR XML AUTO, XMLDATA <Schema name="Schema1" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft- com:datatypes"> <ElementType name="Orders" content="empty“ model="closed"> <Schema name="Schema1" xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft- com:datatypes"> <ElementType name="Orders" content="empty“ model="closed">

Binary Data SELECT EmployeeID, Photo FROM Employees WHERE EmployeeID = 10 FOR XML AUTO SELECT EmployeeID, Photo FROM Employees WHERE EmployeeID = 10 FOR XML AUTO <Employees EmployeeID="1" <Employees EmployeeID="1" SELECT EmployeeID, Photo FROM Employees WHERE EmployeeID = 1 FOR XML AUTO, BINARY BASE64 SELECT EmployeeID, Photo FROM Employees WHERE EmployeeID = 1 FOR XML AUTO, BINARY BASE64 <Employees EmpID="1" Photo="FRwvAAIAAAANAA4AFAAhAP////9Ca..."/> <Employees EmpID="1" Photo="FRwvAAIAAAANAA4AFAAhAP////9Ca..."/>

Using EXPLICIT Mode  범용테이블을 만들기 위해 T-SQL 작성  원하는 XML 문서형태로 제어 SELECT 1 AS Tag, NULL AS Parent, OrderID AS [Invoice!1!InvoiceNo], OrderDate AS [Invoice!1!Date!Element] FROM Orders WHERE OrderID = FOR XML EXPLICIT SELECT 1 AS Tag, NULL AS Parent, OrderID AS [Invoice!1!InvoiceNo], OrderDate AS [Invoice!1!Date!Element] FROM Orders WHERE OrderID = FOR XML EXPLICIT T00:00: T00:00:00

범용 테이블  XML 문서의 특정형식 ( 행집합 ) Tag,Parent 계층구조 결정 Tag,Parent 계층구조 결정 Column 이름은 element / attribute 로 매핑 Column 이름은 element / attribute 로 매핑 TagParent Invoice!1! InvoiceNo Invoice!1!Date! Element LineItem!2! ProductID LineItem!2 1NULL T00:00:00NULLNULL NULL11 Queso Cabrales NULL42 Singaporean …

예 ) EXPLICIT  UNION ALL 이용 SELECT 1 AS Tag, NULL AS Parent, OrderID AS [Invoice!1!InvoiceNo], OrderDate AS [Invoice!1!Date!Element], NULL AS [LineItem!2!ProductID], NULL AS [LineItem!2] FROM Orders WHERE OrderID=10248 UNION ALL SELECT 2 AS Tag,1 AS Parent, OD.OrderID, NULL, OD.ProductID, P.ProductName FROM [Order Details] OD JOIN Orders O ON OD.OrderID=O.OrderID JOIN Products P ON OD.ProductID = P.ProductID WHERE OD.OrderID=10248 ORDER BY [Invoice!1!InvoiceNo], [LineItem!2!ProductID] FOR XML EXPLICIT SELECT 1 AS Tag, NULL AS Parent, OrderID AS [Invoice!1!InvoiceNo], OrderDate AS [Invoice!1!Date!Element], NULL AS [LineItem!2!ProductID], NULL AS [LineItem!2] FROM Orders WHERE OrderID=10248 UNION ALL SELECT 2 AS Tag,1 AS Parent, OD.OrderID, NULL, OD.ProductID, P.ProductName FROM [Order Details] OD JOIN Orders O ON OD.OrderID=O.OrderID JOIN Products P ON OD.ProductID = P.ProductID WHERE OD.OrderID=10248 ORDER BY [Invoice!1!InvoiceNo], [LineItem!2!ProductID] FOR XML EXPLICIT

OPENXML  OPENXML syntax Row 를 결정하기 위해 rowpattern parameter 사용 Row 를 결정하기 위해 rowpattern parameter 사용 컬럼을 결정하기 위해 WITH 구문사용 컬럼을 결정하기 위해 WITH 구문사용 Attribute 를 결정하기 위해 Flags parameter 사용 Attribute 를 결정하기 위해 Flags parameter 사용 SELECT * FROM OpenXML 'order', 1) WITH (orderno integer, orderdate datetime) SELECT * FROM OpenXML 'order', 1) WITH (orderno integer, orderdate datetime)

OPENXML 적용방법  sp_xml_preparedocument 으로 트리생성  sp_xml_removedocument 메모리 해제 CREATE PROC NText AS integer EXEC -- Process Document EXEC CREATE PROC NText AS integer EXEC -- Process Document EXEC

예 ) Inserting Data  INSERT 구문  SELECT INTO 구문 INSERT orders SELECT * FROM OpenXML 'order', 1) WITH (orderno integer, orderdate datetime) INSERT orders SELECT * FROM OpenXML 'order', 1) WITH (orderno integer, orderdate datetime) SELECT * INTO neworders FROM OpenXML 'order', 1) WITH (orderno integer, orderdate datetime) SELECT * INTO neworders FROM OpenXML 'order', 1) WITH (orderno integer, orderdate datetime)

Using rowpattern  Xpath 를 사용 SELECT * FROM OpenXML 'order/lineitem', 1) WITH (productid integer, quantity integer, price money) SELECT * FROM OpenXML 'order/lineitem', 1) WITH (productid integer, quantity integer, price money) SELECT * FROM OpenXML 1) WITH (productid integer, quantity integer, price money) SELECT * FROM OpenXML 1) WITH (productid integer, quantity integer, price money)

Using Flags  attributes 또는 elements 지정하기 위해 사용 0 = default (attributes) 0 = default (attributes) 1 = attributes 1 = attributes 2 = elements 2 = elements 3 = attributes elements (1 + 2) 3 = attributes elements (1 + 2)

Using a Table Name  WITH 구문에 테이블 이름 사용 컬럼이름이 match 컬럼이름이 match 데이터 타입이 호환 데이터 타입이 호환 INSERT lineitems SELECT * FROM OpenXML 'order/lineitem', 3) WITH lineitems INSERT lineitems SELECT * FROM OpenXML 'order/lineitem', 3) WITH lineitems

Column Pattern  계층구조에서 데이터를 처리하기 위해 Xpath 사용  relative XPath 적용 INSERT lineitems SELECT * FROM OpenXML 'order/lineitem', 1) WITH (orderno integer productid integer, --Default Mapping quantity integer './quantity', price money --Default Mapping) INSERT lineitems SELECT * FROM OpenXML 'order/lineitem', 1) WITH (orderno integer productid integer, --Default Mapping quantity integer './quantity', price money --Default Mapping)