460 likes | 615 Views
Session id: 40108. Making XML Technology Easier to Use. X M L T O T H E P O W E R O F S Q L. Jinyu Wang Senior Product Manager Oracle Corporation. Scott Brewton Principal Instructor Oracle Corporation. XML Widely Accepted. Expanding the business
E N D
Session id: 40108 Making XML Technology Easier to Use X M L T O T H E P O W E R O F S Q L Jinyu WangSenior Product Manager Oracle Corporation Scott BrewtonPrincipal InstructorOracle Corporation
XML Widely Accepted • Expanding the business • XML is widely accepted as the standard data exchange format for B2B, B2C and EAI applications • Making use of the legacy applications • XML incorporates metadata with data facilitating cross platform data exchange • Building e-business applications over the Internet • XML provides powerful data abstraction for transaction data management and exchange • Publishing content across media and device types • XML provides flexible content representations and easy transformations
Why Simplify the Use of XML • XML is not easy to pick up • Complex XML syntax • Bewildering array of new specs and APIs • XML is not straightforward to process • Lack of business logic in the document-centric APIs • Difficult to connect XML resources • XML is overly extensible • Many different ways to extend • Lack of design guidance • XML metadata processing inefficient
XDK Simplify the XML Development • Simplifies XML parsing • New DOM 3.0 support • New Built-in SAX output interface • Provides simple and powerful XSL transformations • New XSLT 2.0 and XPath 2.0 support • Easily uses Java with XML binding to Java Objects • New JAXB Class Generator • Uses the stream-based XML metadata processing • New XML Schema validation interfaces • Declaratively connects XML processing resources • New XML Pipeline Processor
Document Entity Ref Element Element Element CDATA Text Attr XML DOM Parser DOM XML Parsing • A set of object-based APIs that loads an XML document into the memory and represents it as a DOM tree DOM Tree
DOM 3.0: Load and Save • Standardizes the XML parsing process • DOMInputStream, DOMReader • Standardizes the DOM serialization process • DOMOutputStream, DOMWriter • Allows filtering XML Content during DOM construction • DOMParserFilter • Provides asynchronous XML DOM parsing • DOMImplementationLS.MODE_ASYNCHRONOUS
XML XML* DOM Parser DOM LS: Standard and Flexible DOM Parsing • Standard Input/output facilitates portable implementation • Content Filtering reduces the DOM object footprint • Async data access enables efficient XML application Application EventListner Register Notify Filter Input Output * Will be in different formats
D E M O N S T R A T I O N DOM 3.0 Load and Save
DOM 3.0: Validation • Retrieves Metadata Definitions in XML Schema • getDefinedElements • getDefaultValue • getAllowedParents, getAllowedChildren etc. • getContentType • Responds to queries for DOM update operations • canAppendChild, canReplaceChild, canRemoveChild, canInsertBefore() • Validates the DOM document and DOM fragments • validateDocument, nodeValidity
Document Entity Ref Element Element Element CDATA Text Attr XSD XSD DOM Parser DOM Validation: Simplify XML Editing • XML Schema provides guidance when updating XML • Validation ensures valid structure of XML documents User DOM Tree
D E M O N S T R A T I O N DOM 3.0 Validation
StartDocument EndDocument StartElement EndElement XML SAX Parser SAX XML Parsing • A set of event-based APIs that report XML parsing events through callback functions. Streaming Streaming …… SAX Events
SAX Output Serialization • Build-in Java class handles the SAX output serialization • oracle.xml.parser.v2.SAXPrintDriver • Flexible output options for the SAX output • Pretty printing or indenting • XML Encoding • XML declaration • CDATA elements • DTD system-id and public-id • Simple interface as a SAX Content Handler • OracleXMLQuery.getXMLSAX(sample);
StartDocument EndDocument StartElement EndElement XML XSU Simplify the Output of SAX Steaming • Streaming without complicated callback functions • Flexible build-in output options simplifies content delivery SQL Query Streaming …… JDBC 10g
Example for New SAX Output import oracle.xml.parser.v2.XMLSAXPrintDriver; //Open a File OutputStream out=new FileOutputStream("out.xml"); DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver()); conn= DriverManager.getConnection(thinConn, “SH”, “SH”); XMLSAXPrintDriver sample=new XMLSAXPrintDriver(out); // Initialized the OracleXMLQuery OracleXMLQuery qry=new OracleXMLQuery(conn, "select * from sales"); qry.getXMLSAX(sample); sample.flush(); • Hands-on Lab: Build Database Applications Lesson 9
JSP, SQL… HTML SVG PDF XML XSL XML XSL XSLT Transformation • Transforms and formats one or more XML documents to text-based outputs through XSLT Stylesheets …… XSLT Processor Text Outputs
Simplify XSLT with XSLT 2.0 • Enables efficient content grouping with simple syntax • New built-in grouping support • Eliminates node-set conversion • New temporary tree support • Permits flexible content delivery • New multiple output serialization • Avoids error-prone character escaping • New character mapping support
Grouping • What is Grouping • Uses <xsl:for-each-group> to select items • Uses options to specify how items are grouped : • group-by • group-adjacent • group-starting-with • group-ending-with • Refers to current group members with current-group() • Value of This Feature • Greatly simplifies the grouping operations • Allows efficient content processing
Example for Grouping <xsl:for-each-groupselect=“CATALOG//CD“group-by="COUNTRY"> <xsl:sortselect="COUNTRY"/> <COUNTRY name="{COUNTRY}"> <xsl:for-each-groupselect="current-group()" group-by="YEAR"> <YEAR year="{YEAR}"> <xsl:for-each select="current-group()"> <xsl:copy-of select="current-group()/TITLE" /> </xsl:for-each> </YEAR> </xsl:for-each-group> </COUNTRY> </xsl:for-each-group>
D E M O N S T R A T I O N XSLT 2.0: Grouping
Temporary Tree • What is Temporary Tree • Constructed by evaluating an <xsl:variable>, <xsl:param> or <xsl:with-param> • Accessible using XPath expressions • Processed by the <xsl:apply-templates>, <xsl:for-each> instructions • Processed by Key() and id()XPath functions • Value of this Feature • Eliminates node set conversions • Breaks up complex transformation into several steps • Allows iterative processing on XML documents
Example for Temporary Tree <xsl:variable name="catalog"> <CATALOG> <CD> <TITLE>Empire</TITLE>… <YEAR>1985</YEAR> </CD> … <CD> <TITLE>Still got the blues</TITLE>… <YEAR>1990</YEAR> </CD> </CATALOG> </xsl:variable> <xsl:apply-templatesselect="$catalog//CD[number(YEAR)>=1988]/TITLE"/>
D E M O N S T R A T I O N XSLT 2.0: Temporary Tree
Multiple Output Serialization • What is Multiple Output Serialization • Creating multiple results from one XSLT Stylesheet • Using <xsl:result-document> • Value of this Feature • Paginates output • Generates pages using HTML Frames • Creates HTML, SVG and CSS document at one step
Example for Multiple Result Documents <xsl:output method="xml" indent="yes" name="cd-format"/> <xsl:template match="/"> <xsl:for-each-groupselect="/CATALOG//CD" group-by="COUNTRY"> <xsl:result-document href="../output/CD_{current-group()/COUNTRY}.xml" format="cd-format"> <CD_LIST country="{current-group()/COUNTRY}"> <xsl:copy-of select="current-group()"/> </CD_LIST> </xsl:result-document> </xsl:for-each-group> </xsl:template>
D E M O N S T R A T I O N XSLT 2.0: Multiple Outputs
Flexible Character Mapping • What is Character Mapping • Specifies characters to stand for escaped string • Uses <xsl:character-map> and <xsl:output-character> • Specifies character to string mapping using Unicode Private Use Area (between #xE000 and #xF8FF) • Value of This Feature: • Robustly controls the character escaping • Provides consistent transformed results • Simplifies code generation using XSLT
Example for Character Mapping <xsl:outputuse-character-maps="jsp"/> <xsl:character-mapname="jsp"> <xsl:output-charactercharacter="" string="<%"/> <xsl:output-charactercharacter="" string="%>"/> </xsl:character-map> <xsl:template match="/">@ page language="java"  <HTML> <BODY> myvariable String; </BODY> </HTML> </xsl:template>
D E M O N S T R A T I O N XSLT 2.0: Character Mapping
XML Schema Processor • Validates the XML documents against XML schemas • Supports LAX and STRICT validation modes • XMLParser.SCHEMA_LAX_VALIDATION • XMLParser.SCHEMA_STRICT_VALIDATION • Supports simple datatypes and complex structures within XML documents
New XML Schema Validation APIs • Retrieving XML Schema validation mode • getCurrentMode() • Looking up XML elements and attribute content types • getElementDeclaration() • getAttributeDeclarations() • Obtaining associated XML Schema annotations • getAnnotation()
XML XML XSD XML Schema Processor User Applications Streaming XML Schema Processing • New APIs allow synchronized metadata retrieval during SAX Streaming SAX SAX Query
Example for XML Schema Validation APIs • Oracle Database Demo Booth #GG
Java Architecture for XML Binding • Binding Language • Describes the binding of source schema to a set of derived packages and classes • Schema Compiler • Generates Java classes from XML schemas • Binding Runtime Framework • Unmarshalling: reads XML and construct Java objects tree • Marshalling: traverses Java object tree and generate XML • Validation: verifies XML Schema constraints on Java objects
ARTIST PRICE TITLE YEAR CD JAXB: Easy to Manipulate XML Content Create XML using DOM : Element Title, cd; Text txt; Title = CreateElement(“Title”); cd.appendChild(title); txt=CreateTextElement(“…”); Title.appendChild(txt); Unmarshalling XML using JAXB: CDRecord.setTitle(…)
D E M O N S T R A T I O N JAXB Class Binding
XML Pipeline Processing • Pipeline Document in XML Vocabulary • Specifies the inputs and outputs for XML processes • Describes the processing relationships • Supports XML Parsing, XSD Validation, XSL Transformation and XML compression • Pipeline Controller • Establishes a reusable component framework • Executes the chains of XML processing • Returns the a particular results • Optimizes the XML processing
XML Pipeline: Declarative programming Declaration 1 <pipelinexmlns="http://www.w3.org/2002/02/xml-pipeline“> <paramname="target" select="myresult.html"/> <processdef name="domparser.p“ definition="oracle.xml.pipeline.processes.DOMParserProcess"/> <processdef name="xslstylesheet.p“ definition="oracle.xml.pipeline.processes.XSLStylesheetProcess"/> <processdef name="xslprocess.p“ definition="oracle.xml.pipeline.processes.XSLProcess"/> <process id="p2" type="xslstylesheet.p" ignore-errors="false"> <input name="xsl" label="book.xsl"/> <outparam name="stylesheet" label="xslstyle"/> </process>… </pipeline> Processing Definitions 2 3 Processing Flow
XSL XML XSD Out XML Pipeline: Simplify XML Processing • Establishes reusable XML Processing Framework • Declarative connection of XML resources XML Parser XSD Processor XSL Processor XML Compressor
D E M O N S T R A T I O N XML Pipeline Processing
Next Steps…. • Recommended sessions • 40020: Building High-Performance Enterprise XML Applications with Oracle Database 10g • 40255: Manipulating XML with Oracle JDeveloper • Recommended demos and/or hands-on labs • DB: Application Development: XML to the Power of SQL • AS: XML Technologies: Simplify Information Integration • See Your Business in Our Software • 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. • Relevant web sites to visit for more information • XML Technology Center – otn.oracle.com/tech/xml
Q & Q U E S T I O N S A N S W E R S A
Reminder – please complete the OracleWorld online session surveyThank you.
XML Developer’s Kit XML TO THE POWER OF SQL