1 / 46

Making XML Technology Easier to Use

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

verena
Download Presentation

Making XML Technology Easier to Use

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. 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

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. D E M O N S T R A T I O N DOM 3.0 Load and Save

  9. 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

  10. 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

  11. D E M O N S T R A T I O N DOM 3.0 Validation

  12. 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

  13. 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);

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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

  19. 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>

  20. D E M O N S T R A T I O N XSLT 2.0: Grouping

  21. 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

  22. 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"/>

  23. D E M O N S T R A T I O N XSLT 2.0: Temporary Tree

  24. 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

  25. 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>

  26. D E M O N S T R A T I O N XSLT 2.0: Multiple Outputs

  27. 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

  28. Example for Character Mapping <xsl:outputuse-character-maps="jsp"/> <xsl:character-mapname="jsp"> <xsl:output-charactercharacter="&#xE001;" string="&lt;%"/> <xsl:output-charactercharacter="&#xE002;" string="%&gt;"/> </xsl:character-map> <xsl:template match="/">&#xE001;@ page language="java" &#xE002; <HTML> <BODY>&#xE001; myvariable String; &#xE002;</BODY> </HTML> </xsl:template>

  29. D E M O N S T R A T I O N XSLT 2.0: Character Mapping

  30. 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

  31. 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()

  32. XML XML XSD XML Schema Processor User Applications Streaming XML Schema Processing • New APIs allow synchronized metadata retrieval during SAX Streaming SAX SAX Query

  33. Example for XML Schema Validation APIs • Oracle Database Demo Booth #GG

  34. 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

  35. 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(…)

  36. D E M O N S T R A T I O N JAXB Class Binding

  37. 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

  38. 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

  39. 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

  40. D E M O N S T R A T I O N XML Pipeline Processing

  41. 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

  42. Q & Q U E S T I O N S A N S W E R S A

  43. Reminder – please complete the OracleWorld online session surveyThank you.

  44. XML Developer’s Kit XML TO THE POWER OF SQL

More Related