1 / 27

Oracle XML Developer’s Kit – XDK Spring 2002

Oracle XML Developer’s Kit – XDK Spring 2002. An Example of XML. <?xml version="1.0" ?> <!DOCTYPE transaction (View Source for full doctype...) > - <transaction> <account> 89-344 </account> - <buy shares=" 100 "> <ticker exch=" NASDAQ "> WEBM </ticker> </buy>

kerryn
Télécharger la présentation

Oracle XML Developer’s Kit – XDK Spring 2002

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. Oracle XML Developer’s Kit – XDKSpring 2002

  2. An Example of XML • <?xml version="1.0" ?> • <!DOCTYPE transaction (View Source for full doctype...)> • - <transaction> • <account>89-344</account> • - <buy shares="100"> • <ticker exch="NASDAQ">WEBM</ticker> • </buy> • - <sell shares="30"> • <ticker exch="NYSE">GE</ticker> • </sell> • </transaction>

  3. Oracle XDK Definition Is Oracle’s collection of XML-based tools for reading, manipulating, transforming, and viewing XML documents.

  4. XDK for C XDK for PL/SQL XDK for C++ XDK for Java XDK Language Support

  5. XML Parser for Java XML Schema Processor for Java XML Class Generator for Java XSQL Servlet XDK Components & Utilities

  6. XML Parsing Definition The process of converting the unstructured sequence of characters representing an XML document into the structured components such as XML syntax, declaration, comments, elements, attributes, processing instructions, and characters.

  7. XML Parsing Process

  8. Markup Definition • An encoded description of a document’s storage layout and logical structure.

  9. XML parser for Java Java supports two XML parser APIs • SAX parser API (Event based Simple API) • DOM parser API (Tree based Document Object Model)

  10. SAX API (Event Based) • SAX API uses calls to report parsing events to the application. • Events include the start and end of elements or characters. e.g. <transaction> . . .</transaction> <countNum>8923</countNum>

  11. DOM API (Tree Based) • DOM API builds an in-memory tree representation of the XML document. It provides classes and methods for an application to navigate and process the tree.

  12. XML Parser for Java using SAX API Import org.xml.sax.*; Import oracle.xml.parser.v2. *; public static void main(String[], argv) { try { // Get an instance of the parser Parser parser = new SAXParser(); // Create a SAX event handler and register it with the parser SAXHandler handler = new SAXHandler(); parse.setDocumentHandler(handler); // Convert file to InputSource and parse InputSource xmldoc = new InputSource(new FileInputStream(argv[0])); parser.parse(xmldoc); } catch (Exception e) {…} }

  13. Xml Parser for Java using DOM API • Import java.xml.parser.v2.DOMparser; • Import org.w3c.dom.*; • Import org.w3c.dom.Node; • Import oracle.xml.parser.v2.XMLElement; • Import oracle. Xml.parser.v2.XMLAttr; … // generate a new input stream from given file FileInputStream xmldoc = new FileInputStream(avgv[0]); // parse the document using domparser DOMParser parser = new DOMParser(); parser.parse(xmldoc); // obtain the document. Document doc = parser.getDocument(); // print some information regarding attributes of elements in the document printElementAtrributes(doc); …

  14. SAX is useful for applications that do not need to manipulate the XML tree, such as search operations, among others. DOM is most useful for structural manipulations of the XML tree, such as reordering elements, adding or deleting elements and attributes, renaming elements, and so 0n. SAX Versus DOM

  15. DOM API & SAX API • DOM API is more powerful; however, it is memory intensive. • SAX API is fast, less memory is needed, and it works for extreme large document.

  16. To run the parsing programs: • Add xmlparserv2.jar and the current directory to the CLASSPATH. • Run the program for DOM/SAX APIs as follows: • java <classname> <sample xml file>

  17. XML Schema for Java • XML Schema is being drawn up by W3C to describe the content and structure of XML documents in XML. It includes the full capabilities of DTDs so that existing DTDs can be converted to XML Schema. XML Schemas have additional capabilities over DTDs.

  18. How to Run XML Schema for Java • Add xmlparserv2.jar, xschema.jar, and the current directory to the CLASSPATH. • E.g. to run the program with the report.xml file, the command line is: • java XSDSample report.xml

  19. XML Class Generators for Java • XML provides two Class Generators for Java: • DTD Class Generator • XML Schema Class Generator

  20. XML Class Generator for Java • Creates Java source files based on: • XML DTDs • XML Schema Definition • It can be used when an application wants to send an XML message to another application based on agreed-upon DTDs or XML Schemas.

  21. XSQL Servlet Definition • It is a Java servlet that can run in the Web server to produce dynamic XML documents based on one or more SQL queries. • It combines the power of SQL, XML, and XSLT to publish dynamic web content based on database information

  22. XSQL Pages Usage • It is an XML file that contains specific elements to direct the action of the servlet. • XSQL page is server-side template. It can publish any information in any format to any device

  23. Basic XSQL Features • Producing XML Datagrams from SQL Queries • Transforming the XML Datagram into an Alternative XML Format • Transforming the XML Datagram into HTML for displaying

  24. Architecture of the XSQL

  25. XSQL Example <!----EmpOver2000.xsql--- > <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="EmpOver2000.xsl"?> <xsql:query connection=“myDemo" xmlns:xsql="urn:oracle-xsql"> SELECT empno, ename, sal, deptno FROM emp where sal > '{@salary}' ORDER BY ename DESC </xsql:query>

  26. XSQL Example (cont.) <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Import all the templates from "TableBaseWithCSS.xsl" as a base --> <xsl:import href="TableBaseWithCSS.xsl"/> <!-- Override Imported template for ROW to match ROW's with a SAL > 2000 --> <xsl:template match="ROW[ SAL > 2000 ]"> <tr class="Highlight"><xsl:apply-templates/> </tr> </xsl:template> </xsl:stylesheet>

More Related