Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

Mark V. Scardina, Ben ChangandJinyu Wang

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








Configuring the Oracle XML DB


To configure the Oracle XML DB, you can update the xdbconfig.xml file using the DOM PL/SQL APIs and DBMS_XDB package or the graphical interface provided in Oracle Enterprise Manager (OEM). The OEM allows you to insert, remove, or update the content of the XML elements in xdbconfig.xml. In this section, we discuss the PL/SQL operations.



Understanding xdbconfig.xml



The xdbconfig.xml file is an XML file that is stored as a resource in the Oracle XML DB Repository. It conforms to the XML schema defined in /sys/schemas/PUBLIC/xmlns.oracle.com/xdb/ xdbconfig.xsd in the Oracle XML DB Repository File. It has the following data structure:


<xdbconfig>  
<sysconfig> ... </sysconfig>
<userconfig> ... </userconfig>
</xdbconfig>


The top-level <xdbconfig> tag contains two sections:





<sysconfig> Lists all the system-specific setups and the built-in parameters.





<userconfig> Lists all parameters that allow users to customize the setups.





The <sysconfig> section contains the following content:


 <sysconfig>  
General parameters
<protocolconfig> ... </protocolconfig>
</sysconfig>


It stores the general parameters that apply to the Oracle XML DB; for example, the maximum age for an access control list (ACL), whether Oracle XML DB should be case sensitive, and so on. In <sysconfig>, the protocol parameters are grouped inside the <protocolconfig> tag, which has the following data structure:


 <protocolconfig>  
<common> ... </common>
<httpconfig> ... </httpconfig>
<ftpconfig> ... </ftpconfig>
</protocolconfig>


The <common> element stores the parameters that apply to all protocols, such as MIME type information. The HTTP- and FTP-specific parameters are stored under the sections <httpconfig> and <ftpconfig>, respectively. The <httpconfig> section contains the <webappconfig> element for web-based application configurations, including the icon name and display name for the applications, and a list of servlets in Oracle XML DB.



Configuring xdbconfig.xml



In SQL*Plus, you can use DBMS_XMLDB.CFG_GET() to retrieve the current content of xdbconfig.xml as follows:


 VAR out CLOB 
SET AUTOPRINT ON
BEGIN
:out := DBMS_XDB.CFG_GET().GETCLOBVAL();
END;





Note


To be able to see the content, you need to run SET LONG 100000 to increase the size of the display buffer for SQL*Plus.




The DBMS_XDB.CFG_GET() function returns a copy of the xdbconfig.xml configuration as an XMLType and it automatically commits after each execution:


 DBMS_XDB.CFG_GET() RETURN SYS.XMLTYPE 


If you have many parameters to update in the xdbconfig.xml file, you can use the DBMS_ XDB.CFG_UPDATE() function. It replaces the content of the xdbconfig.xml file with the content in the input XMLType:


 DBMS_XDB.CFG_UPDATE(newconfig SYS.XMLTYPE) 


After the configuration parameters are updated, you need to call the DBMS_XDB.CFG_ REFRESH() function to make sure the Oracle XML DB picks up the new updated configuration:


 DBMS_XDB.CFG_REFRESH(); 


For example, if you need to configure the port numbers for Oracle XML DB HTTP and FTP servers to use other than the default values (HTTP: 8080, FTP: 2100), you can follow these steps:





Log in to a SQL*Plus session and connect as the XDB user (assuming the password for XDB user is xdbpw):


 > sqlplus xdb/xdbpw  




Call DBMS_XDB.CFG_UPDATE() to update the HTTP port:


 DECLARE 
config XMLType;
BEGIN
config := DBMS_XDB.CFG_GET();
SELECT UPDATEXML(config,
'/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()',
8081,
'/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()',
2121) into config
FROM DUAL;
DBMS_XDB.CFG_UPDATE(config);
END;





Call DBMS_XDB.CFG_REFRESH() to ensure the Oracle XML DB picks up the new settings:


 SQL> EXEC DBMS_XDB.CFG_REFRESH();  




To check the HTTP and FTP port numbers, you can use the following SQL query:


 SELECT  
EXTRACTVALUE(DBMS_XDB.CFG_GET(),
'/xdbconfig/sysconfig/protocolconfig/httpconfig/http-port/text()')
AS httpport,
EXTRACTVALUE(DBMS_XDB.CFG_GET(),
'/xdbconfig/sysconfig/protocolconfig/ftpconfig/ftp-port/text()')
AS ftpport
FROM dual;





Normally, you just need to update the content in the configuration file. However, sometimes you need to insert a new element into this file. For example, if you want the Oracle XML DB Repository to properly handle Scalar Vector Graphics (SVG) files, you need to add a new MIME entry in xdbconfig.xml, as follows:


 <mime-mapping 
xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd">
<extension>svg</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>


Since the current UPDATEXML() function does not append new XML child elements, you need to update the content of <mime-mappings>, which includes all the MIME mapping definitions. In such cases, using the DOM API in PL/SQL provides efficient XML updates:


 CREATE OR REPLACE PROCEDURE AddNewElement(p_xpath IN VARCHAR2, 
p_content IN VARCHAR2,
p_namespace IN VARCHAR2) AS
v_config XMLType;
v_mimemap XMLType;
v_doc DBMS_XMLDOM.DOMDocument;
v_doc_elem dbms_xmldom.DOMElement;
v_xsl DBMS_XSLPROCESSOR.Processor;
v_subdoc dbms_xmldom.DOMDocument;
v_subdoc_elem dbms_xmldom.DOMElement;
v_node dbms_xmldom.DOMNode;
v_impnode dbms_xmldom.DOMNode;
BEGIN
v_mimemap := XMLType.createXML(p_content);
v_config := DBMS_XDB.CFG_GET();
v_doc := DBMS_XMLDOM.newDOMDocument(v_config);
v_doc_elem := DBMS_XMLDOM.getDocumentElement(v_doc);
v_node := DBMS_XSLPROCESSOR
.selectSingleNode(DBMS_XMLDOM.makeNode(v_doc),
p_xpath, p_namespace);
v_subdoc :=DBMS_XMLDOM.newDOMDocument(v_mimemap);
v_subdoc_elem := DBMS_XMLDOM.getDocumentElement(v_subdoc);
v_impnode := DBMS_XMLDOM.importNode(v_doc,
DBMS_XMLDOM.makeNode(v_subdoc_elem), true);
v_node := DBMS_XMLDOM.appendChild(v_node, v_impnode);
DBMS_XDB.CFG_UPDATE(v_config);
END;
/


Using this procedure, we can add a new MIME mapping for SVG files:


 BEGIN 
AddNewElement(
'/xdbconfig/sysconfig/protocolconfig/common/extension-mappings/
mime-mappings', '<mime-mapping xmlns=
"http://xmlns.oracle.com/xdb/xdbconfig.xsd">
<extension>svgjinyu</extension>
<mime-type>image/svg+xml</mime-type></mime-mapping>',
'xmlns="http://xmlns.oracle.com/xdb/xdbconfig.xsd"');
END;
/


/ 218