1 / 20

June 2007

Using ORACLE XML Parser to Access Ontology. CMPE 588 Engineering Semantic for Web Information System TERM PROJECT REPORT. June 2007. Goal.

xerxes
Télécharger la présentation

June 2007

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. Using ORACLE XML Parser to Access Ontology CMPE 588 Engineering Semantic for Web Information System TERM PROJECT REPORT June 2007

  2. Goal This project addresses the issue of useing protégé to create the ontology of geographic locations, and using the software racer to chick its consistency. Some annotation will be added to ontology and utilized for search process. Then, generate the XML format of the ontology, and load onto ORACLE database, then using ORACLE XML parser for PL/SQL to access the contents of the XML file of the ontology. Finally, XPath expression is used to search the XML documents The results of SQL queries will be transformed into any desired XML format using XSLT stylesheets, and to be browsed by explorer.

  3. Classical techniques and methodologies are largely inadequate because of the inherent autonomous and heterogeneous nature of the information resources which force applications to share data and respective services, often without prior knowledge of their structures functionality. Developing ontology, as a unifying resource, would be of great importance for the researcher to be able to solve this problem.

  4. In this project, I am suggesting some Ontology with four main branches: • Address • City • State • Country • Continent Fig. 1: Geographic LocationsOntology and its five main sub-ontologies: Address, City, Country, State, and Continent.

  5. Case StudySearch for the cities annotated Holy cities ============================================== We will see that the annotations of the instance will be treated as attributes

  6. Why Should I Use XML? 1. XML Enables a Data Web of Information Services. 2. XML Simplifies Application Integration. 3. XML Simplifies Information Publishing and Reuse. Fig. 2. XML and HTTP can connect different applications

  7. Overview of key Oracle technologies for XML

  8. Using the Oracle XML Parser, you can parse XML documents into their infoset, manipulate their contents, and return the modified infoset back into XML format. Using the Oracle XSLT processor, you can transform XML into XML, HTML, or text of another structure. Both the Oracle XML Parser and the Oracle XSLT processor share the common Oracle XPath Engine that enables querying an XML document's infoset to select interesting subsets of its information. The Oracle XML SQL Utility automates the tasks of producing XML from SQL query results and storing XML documents into tables in the database. Oracle interMedia Text enables indexing and querying of XML documents or document fragments, with rich support for leveraging the structure of the XML in the query criteria. These core components are used by more than 40 of Oracle's own internal development teams, so their quality, performance, and conformance to W3C standards are very high.

  9. CREATE DIRECTORY xmlfiles AS 'C:\term_project_588\xmlfiles'; • Generate XML file format of the ontology and saved in the mentioned directory. • Now we're ready to load the document into the database. We have two choices: • Save a handle to the external file in a column of type BFILE (built-in datatype for external files). • Save a copy of the contents of the external file in a column of type CLOB. • CREATE TABLE xml_documents ( docname VARCHAR2(200) Primary Key, xmldoc CLOB, timestamp DATE);

  10. To store an external XML file into xml_documents table, we are to follow these steps: • Insert a new row into xml_documents with an empty CLOB for the xmldoc column. • Retrieve the empty CLOB into a variable. • Get a BFILE handle to the external file. • Open the file for reading. • Copy the contents of the file into the CLOB variable. • Close the file and COMMIT. I will create a stored procedure, I will call it insertXMLFile , that accepts as arguments the directory name, the filename, and the name you'd like to associate with the document as its primary key. EXEC insertXmlFile('XMLFILES', 'geographic.xml');

  11. CREATE OR REPLACE PROCEDURE insertXmlFile( dir VARCHAR2, file VARCHAR2, name VARCHAR2 := NULL) IS theBFile BFILE; theCLob CLOB; theDocName VARCHAR2(200) := NVL(name,file); BEGIN -- (1) Insert a new row into xml_documents with an empty CLOB, and -- (2) Retrieve the empty CLOB into a variable with RETURNING..INTO INSERT INTO xml_documents(docname,xmldoc) VALUES(theDocName,empty_clob( )) RETURNING xmldoc INTO theCLob; -- (3) Get a BFile handle to the external file theBFile := BFileName(dir,file); -- (4) Open the file dbms_lob.fileOpen(theBFile); -- (5) Copy the contents of the BFile into the empty CLOB dbms_lob.loadFromFile(dest_lob => theCLob, src_lob => theBFile, amount => dbms_lob.getLength(theBFile)); -- (6) Close the file and commit dbms_lob.fileClose(theBFile); COMMIT; END; /

  12. Verifying proper installation of Oracle XML Parser for PL/SQL We can verify proper installation by running the following SQL statement: SELECT SUBSTR(dbms_java.longname(object_name),1,30) AS class, status FROM all_objects WHERE object_type = 'JAVA CLASS' AND object_name dbms_java.shortname('oracle/xml/parser/v2/DOMParser'); We will have the following output: CLASS STATUS ------------------------------ ------- oracle/xml/parser/v2/DOMParser VALID

  13. Checking that an XML document is well-formed To do so, we need to go through the following steps: • Call xmlparser.newParser to create a new XML Parser for the job. • Call one of the following to parse the document: xmlparser.parse, xmlparser.parseBuffer, or xmlparser.parseCLOB. • Call xmlparser.freeParser to free the instance of the XML Parser. The following procedure will check. Where I have included these steps in the following procedure:

  14. CREATE OR REPLACE PROCEDURE checkXMLInCLOB(c CLOB, wellFormed OUT BOOLEAN, error OUT VARCHAR2) IS parser xmlparser.Parser; xmldoc xmldom.DOMDocument; XMLParseError EXCEPTION; -- Associate the XMLParseError exception with the -20100 error code PRAGMA EXCEPTION_INIT( XMLParseError, -20100 ); BEGIN -- (1) Create a new parser parser := xmlparser.newParser; -- (2) Attempt to parse the XML document in the CLOB xmlparser.ParseCLOB(parser,c); -- (3) Free the parser. xmlparser.freeParser(parser); -- If the parse succeeds, we'll get here wellFormed := TRUE; EXCEPTION -- If the parse fails, we'll jump here. WHEN XMLParseError THEN xmlparser.freeParser(parser); wellFormed := FALSE; error := SQLERRM; END; /

  15. SET SERVEROUTPUT ON DECLARE xmlClob CLOB; wellFormed BOOLEAN; parseError VARCHAR2(200); BEGIN -- Select the CLOB for the document named 'geographic.xml ' into a variable SELECT xmldoc INTO xmlClob FROM xml_documents WHERE docname = 'people.owl.xml'; -- Check it for XML Well-formedness checkXMLInCLOB(xmlClob,wellFormed,parseError); -- Print out an error if it was not well-formed. IF NOT wellFormed THEN dbms_output.put_line(parseError); END IF; END; /

  16. Tools • Protégé 3.2.1, http://protege.stanford.edu; for editing my ontology, I will make use of protégé. Protégé is a free, open source and java based ontology editor. • RacerPro Version 1.9.0 available at http://www.sts.tu-harburg.de/~r.f.moeller/racer/; to automatically compute the classification hierarchy, and also to check the logical consistency of the ontology.

  17. Toolscontinue Protégé is an ontology editor and knowledge-based editor, it provides graphical user interface (GUI) that models classes (domain concepts) and their attributes and relationships in ontology. While RacerPro stands for Renamed ABox and Concept Expression Reasoner Professional, as the reasoning system is required as part of the ontology editing system, RacerPro, will run to find out the inconsistency relation or properties that might appear as the marvelous growth of illnesses symptoms ontology.

  18. Application

  19. Let us go to the application …

More Related