Session id: 40020
Building High-Performance Enterprise XML Applications with Oracle Database 10g Mark Scardina Group Product Manager & XML Evangelist Oracle Corporation
Why You Need XML
Why XML Demands High Performance
y Expanding business –
y Encapsulation of data increase payload size y Standards require character-based processing
XML is widely accepted as the standard data exchange format for B2B, B2C and EAI applications
y Moving legacy applications to the Internet –
–
XML incorporates metadata with data facilitating cross platform data exchange
–
y Building e-Business applications over the Internet –
y XSL transformations require expensive DOM y Content needs data-binding for application processing
XML provides powerful data abstraction for transaction data management and exchange
y Publishing content across media and device types –
XML provides flexible content representations and easy transformations
W3C/JSR Standards Support
Oracle XML Developer’s Kit 10g
Standard
y High Performance Standards-based libraries and utilities to generate, manipulate, render and store XML y Includes: – – – – – – – – –
XML Schema validation XSLT stylesheet transformation
XML
Java, C/C++
1.0
Java, C/C++ Java, C/C++
SAX + Extensions
1.0/2.0
Java, C/C++
XSLT + XPath
1.0/2.0 1.0/2.0
Java, C/C++
XML Schema
1.0
Java, C/C++
SOAP
1.1
Java
JAXP
1.1
Java
JAXB
1.0
Java
DOM
y Available for Java, C, and C++ y Available in Servers and free of charge from OTN
Language
1.0
1.0/2.0/3.0 1.0/2.0/3.0
XML Namespaces
XML Parser XSLT Processor and XSLTVM XML Schema Processor XML Class Generators XML Java Beans XML SQL Utility XSQL Servlet SOAP Services XML Pipeline Processor
Version
Page 1 1
Oracle XDK 10g: XML to the Power of SQL
Build OCI XML DB Applications
y Build Oracle 10g XML OCI Applications –
y New C APIs for working with XMLType y Unified development in/out of Oracle DB 10g
Directly access XMLType DOM
y Utilize High Performance XSL Transformations –
–
XSLT Compiler and Virtual Machine
y Efficiently Generate Large XML documents –
–
y Fast and Efficient XML processing of DB data
Stream-based retrieval
y Speed XML Processing with Stream-based XML
–
One step XML validation and transformation
–
–
Common XML* C interfaces for XML and XMLType Eliminates parsing and DOM construction Directly work with the XMLType DOM (XOB) Eliminates serializing and reparsing
Fast XSLT with Oracle XDK10g
XDK Unified DOM C Code Sample
y XSLT Compiler and VM for C/C++
/* Get an xml context */ params[0].name_ocixmldbparam = XCTXINIT_OCIDUR; params[0].value_ocixmldbparam = &dur; xctx = OCIXmlDbInitXmlCtx(envhp, svchp, errhp, params, 1); /* Parse a schema-based document */ if (!(doc = XmlLoadDom(xctx, &err, "buffer", lpxml_test_sch, "buffer_length", sizeof(tlpxml_test_sch)-1, "validate", TRUE, NULL))) /* Create some elements and add them to the document */ top = XmlDomGetDocElem(xctx, doc); foo = (xmlnode *) XmlDomCreateElem(xctx, doc, (oratext *) "FOO"); foo_data = (xmlnode *) XmlDomCreateText(xctx, doc, (oratext *) "data"); foo_data = XmlDomAppendChild(xctx, (xmlnode *) foo, (xmlnode *) foo_data); foo = XmlDomAppendChild(xctx, quux, foo);
– – –
Compile Stylesheets for execution in XSLTVM Improved throughput up to 2.5x Significant Reduction in Memory use
y XSLT 2.0 Support and Optimizations in Java –
– –
Optimized Stylesheet compilation based on XML/XSL static analysis Indexing eliminates expensive XPath navigation Support for Grouping, Multiple Outputs, Character Mapping, Temp Trees and XSL functions
Throughput Performance (KB/s)
XSLT Compiler and Virtual Machine
Result File Size XSL
XSLT Compiler
XML XML XML
SVG XSLT Virtual Machine
Oracle XSLTVM
Oracle C
Oracle Java
BrandX Java
xslbench1
1442
653
103
13
xslbench2
1773
890
1502
534
xslbench3
9813
4461
3125
928
Overall
1574
654
408
208
HTML CSS WML
Page 2 2
XSLT Compiler/VM Code Sample
Efficiently Generate Large XML Docs
xmlFile = (oratext*)argv[1]; xslFile = (oratext*)argv[2]; /* Create context ad initialize */ xctx = XmlCreate(&err, (oratext *) "sample", "data_encoding", "US-ASCII", NULL); comp = XmlXslCreateComp (xctx); vm = XmlXslVMCreate (xctx); /* Compile XSL stylesheet input file */ code = XmlXslCompileFile (comp, xslFile, NULL, XMLXSL_STRIPSPACE, &err); /* Transform XML input file */ len = XmlXslGetBytecodeLength (code, &err); err = XmlXslVMSetBytecodeBuffer (vm, code, len); err = XmlXslVMTransformFile (vm, xmlFile, NULL);
y y y y y y
Print XML directly from SQL Queries Print Large XML Documents and Result Sets Easily print directly from SAX events Extends XML SQL Utility in Oracle XDK 10g Eliminates the need to create a DOM No need to create SAX handlers
Performance Numbers
Efficiently Generate Large XML
Result Set File Size StartDocument SQL Query
Streaming
StartElement ……
XSU EndElement EndDocument
JDBC
Memory (MB) Time (s) DOM/SAX DOM/SAX
3K Bytes
35/34 35/34
3.72/3.13 3.72/3.13
300K Bytes
38/37 38/37
7.91/4.72 7.91/4.72
3M Bytes
54/37 54/37
37.8/13.4 37.8/13.4
30M Bytes
<100/37 <100/37
?/95.5
XML
10g
Streaming Single-step XML Processing
SAX Print from Query Sample Code //Open a File and Initialize connection and SAX print OutputStream out = new FileOutputStream("out.xml"); DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); conn= DriverManager.getConnection(thinConn,”sh”,”sh”); XMLSAXPrintDriver sample = new XMLSAXPrintDriver(out);
y Create a stream-based XML integration app y Validate and Transform XML messages in a stream-based process y Utilize Oracle Streams 10g messaging support y Annotate XML Schema with mapping attributes y Easily and Efficiently support multiple schemas y Abstract application schema from input schemas future-proofing your application
//init the OracleXMLQuery OracleXMLQuery qry = new OracleXMLQuery(conn,"select * from sales"); //Print the results qry.getXMLSAX(sample); sample.flush();
Page 3 3
Stream-based XML Processing XSD
D E M O N S T R A T I O N XML XML
SAX
XML Schema Processor
SAX
An Open-XML Streaming Business Process Application
User Applications
Query
Existing DB Application Business
Extending DB Application Business
SOA P
SOAP
•PO
•PO Interpretation Validation Input
SO
•Relational •Database
Oracle 10g – The High Performance XML Platform OracleDB XML Database
OracleAS WebCache
OracleAS J2EE
AP
•XML Relational •Database
Interpretation Validation Input
Next Steps…. y Recommended sessions –
Client
–
40108: Making XML Technologies Easier to Use 40255: Manipulating XML with Oracle JDeveloper
y Recommended demos and/or hands-on labs XML Stream
XML Stream
–
XML Stream
–
DB: Application Development: XML to the Power of SQL AS: XML Technologies: Simplify Information Integration
y See Your Business in Our Software – XMLType Persistence XML Query Processing XML Schema Validation XSLT Processing XML Messaging & Queuing
XSLT Processing XML Query Processing XML Schema/DTD Validation XML Caching w/ JAAS security XML J2EE Components XML Messaging & Queuing XML Data Integration
XSLT Processing XML Query Processing XML Caching w/HTTP security
XSLT Processing XML Query Processing XML Caching w/o security
Visit the DEMOgrounds for a customized architectural review, see a customized demo with Solutions Factory, or receive a personalized proposal. Visit the DEMOgrounds for more information.
y Relevant web sites to visit for more information –
XML Technology Center – otn.oracle.com/tech/xml
Page 4 4
Oracle XML Resources •Oracle Technology Network • http://otn.oracle.com • Downloads, Demos, Samples, Papers • XML Support Forum •Oracle9i XML Handbook • Covers all of Oracle XML technology • Includes XDK CD with Samples • Available today from Bookstores
Page 5 5