| Oracle® Database PL/SQL Packages and Types Reference 11g Release 2 (11.2) Part Number E25788-04 |
|
|
PDF · Mobi · ePub |
The DBMS_XMLTRANSLATIONS package provides an interface to perform translations so that strings can be searched or displayed in various languages.
See Also:
For more information, see the Oracle XML DB Developer's GuideThis chapter contains the following sections:
Owned by XDB, the DBMS_XMLTRANSLATIONS package must be created by SYS or XDB. The EXECUTE privilege is granted to PUBLIC. Subprograms in this package are executed using the privileges of the current user.
Table 178-1 DBMS_XMLSTORE Package Subprograms
| Method | Description |
|---|---|
|
Disables translations in the current session so that query or retrieval will take place on the base document ignoring session language values |
|
|
Enables translations in the current session |
|
|
Extracts the translations in |
|
|
Returns the base document with all the translations |
|
|
Merges the translations in |
|
|
Sets the source language to a particular language at the specified XPATH |
|
|
Returns the document in the specified language |
|
|
Updates the translation in a particular language at the specified |
This procedure disables translations in the current session so that query or retrieval will take place on the base document ignoring session language values.
DBMS_XMLTRANSLATIONS.DISABLETRANSLATION;
This procedure enables translations in the current session. This is the default behavior.
DBMS_XMLTRANSLATIONS.ENABLETRANSLATION;
This function and procedure extracts the translations in XLIFF format from either an XMLTYPE or a resource in the XDB Repository.
DBMS_XMLTRANSLATIONS.EXTRACTXLIFF( doc IN XMLTYPE, xpath IN VARCHAR2, namespace IN VARCHAR2 := NULL) RETURN XMLTYPE;
DBMS_XMLTRANSLATIONS.EXTRACTXLIFF( abspath IN XMLTYPE, xpath IN VARCHAR2, namespace IN VARCHAR2 := NULL) RETURN XMLTYPE;
Table 178-2 EXTRACTXLIFF Function Parameters
| Parameter | Description |
|---|---|
|
|
|
|
|
|
|
|
Namespace |
|
|
Absolute path of the resource from which the |
The translations in the XLIFF format
Extracting the Translation from an XMLTYPE
Let doc =
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="fr">
Security Class Example - FR
</title>
<title xml:lang="es">
Security Class Example - ES
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>
Let the xpath = '/securityClass/title'. The output of EXTRACTXLIFF will be as follows:
<xliff version='1.1'>
<file original='' source-language='en' datatype='xml'>
<body>
<trans-unit id='/securityClass/title'>
<source>Security Class Example</source>
<alt-trans>
<target xml:lang='fr'>Security Class Example - FR</target>
<target xml:lang='es'>Security Class Example - ES</target>
</alt-trans>
</trans-unit>
</body>
</file>
</xliff>
Extracting the Translation from a Resource
Let the resource '/public/security.xml' =
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="es">
Security Class Example - ES
</title>
<title xml:lang="fr">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
<privlist>
<privilege name="privilege1"/>
<aggregatePrivilege name="iStorePOApprover">
<title>
iStore Purchase Order Approver
</title>
<privilegeRef name="is:privilege1"/>
<privilegeRef name="oa:submitPO"/>
<privilegeRef name="oa:privilege3"/>
</aggregatePrivilege>
<privilege name="privilege2">
<title xml:lang="en">
secondary privilege
</title>
<title xml:lang="fr" xdb:srclang="true">
secondary privilege - FR
</title>
<columnRef schema="APPS" table="PurchaseOrder" column="POId"/>
<columnRef schema="APPS" table="PurchaseOrder" column="Amount"/>
</privilege>
</privlist>
</securityClass>
And let XPATH = '', then the extracted XLIFF is
<xliff version='1.1'>
<file original='/public/security.xml' source-language='en' datatype='xml'>
<body>
<trans-unit id='/securityClass/title'>
<source>Security Class Example</source>
<alt-trans>
<target xml:lang='fr'>Security Class Example - FR</target>
<target xml:lang='es'>Security Class Example - ES</target>
</alt-trans>
</trans-unit>
</body>
</file>
<file original='/public/security.xml' source-language='fr' datatype='xml'>
<body>
<trans-unit id='/securityClass/privilege[@name="privilege2"/title'>
<source>secondary privilege - FR</source>
<alt-trans>
<target xml:lang='en'>secondary privilege</target>
</alt-trans>
</trans-unit>
</body>
</file>
</xliff>
This function returns the base document with all the translations.
DBMS_XMLTRANSLATIONS.GETBASEDOCUMENT( doc IN XMLTYPE) RETURN XMLTYPE;
The XMLTYPE which contains the base document with all the translations
For example, for doc =
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="fr">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>
For the above document, this subprogram will return:
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="fr">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>
This function merges the translations in XLIFF format into either an XMLTYPE or a resource in the XDB Repository.
DBMS_XMLTRANSLATIONS.MERGEXLIFF( doc IN XMLTYPE, xliff IN XMLTYPE) RETURN XMLTYPE;
DBMS_XMLTRANSLATIONS.MERGEXLIFF( xliff IN XMLTYPE);
Table 178-4 MERGEXLIFF Function & Procedure Parameters
| Parameter | Description |
|---|---|
|
|
|
|
|
Translations in the |
The result of merging 'xliff' into 'doc' at 'xpath'
Merge Translations into an XMLTYPE
Consider the following input XMLTYPE:
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="es">
Security Class Example - ES
</title>
<title xml:lang="fr">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
<privlist>
<privilege name="privilege1"/>
<aggregatePrivilege name="iStorePOApprover">
<title>
iStore Purchase Order Approver
</title>
<privilegeRef name="is:privilege1"/>
<privilegeRef name="oa:submitPO"/>
<privilegeRef name="oa:privilege3"/>
</aggregatePrivilege>
<privilege name="privilege2">
<title xml:lang="en">
secondary privilege
</title>
<title xml:lang="fr" xdb:srclang="true">
secondary privilege - FR
</title>
<columnRef schema="APPS" table="PurchaseOrder" column="POId"/>
<columnRef schema="APPS" table="PurchaseOrder" column="Amount"/>
</privilege>
</privlist>
</securityClass>
Let the input XLIFF be as follows:
<xliff version='1.1'>
<file original='/public/security.xml' source-language='en' datatype='xml'>
<body>
<trans-unit id='/securityClass/title'>
<source>Security Class Example Modified</source>
<alt-trans>
<target xml:lang='fr'>Security Class Example Mod - FR</target>
<target xml:lang='es'>Security Class Example Mod - ES</target>
</alt-trans>
</trans-unit>
<trans-unit id='/securityClass/privilege[@name="privilege2"/title'>
<source>secondary privilege modified</source>
<alt-trans>
<target xml:lang='fr'>secondary privilege mod - FR</target>
</alt-trans>
</trans-unit>
</body>
</xliff>
The output of merge will be as follows:
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example Modified
</title>
<title xml:lang="es">
Security Class Example Mod - ES
</title>
<title xml:lang="fr">
Security Class Example Mod - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
<privlist>
<privilege name="privilege1"/>
<aggregatePrivilege name="iStorePOApprover">
<title>
iStore Purchase Order Approver
</title>
<privilegeRef name="is:privilege1"/>
<privilegeRef name="oa:submitPO"/>
<privilegeRef name="oa:privilege3"/>
</aggregatePrivilege>
<privilege name="privilege2">
<title xml:lang="en" xdb:srclang="true">
secondary privilege modified
</title>
<title xml:lang="fr">
secondary privilege mod - FR
</title>
<columnRef schema="APPS" table="PurchaseOrder" column="POId"/>
<columnRef schema="APPS" table="PurchaseOrder" column="Amount"/>
</privilege>
</privlist>
</securityClass>
Merge XLIFF Translations into a Resource
If the input document in the above example were to be stored in the repository at '/public/security.xml', then merging the above XLIFF will have the same effect.
This function sets the source language to a particular language at the specified XPATH.
DBMS_XMLTRANSLATIONS.SETSOURCELANG ( doc IN XMLTYPE, xpath IN VARCHAR2, lang IN VARCHAR2, namespace IN VARCHAR2 := NULL) RETURN XMLTYPE;
Table 178-5 SETSOURCELANG Function Parameters
| Parameter | Description |
|---|---|
|
|
|
|
|
|
|
|
Source language |
|
|
Namespace |
The updated document
For example, if doc =
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="fr">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>
the statement
setSourceLang ( doc, '/securityClass/title', 'fr' )
produces
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en">
Security Class Example
</title>
<title xml:lang="fr" xdb:srclang="true">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>
This function returns the document in the specified language.
DBMS_XMLTRANSLATIONS.TRANSLATEXML( doc IN XMLTYPE, lang IN VARCHAR2) RETURN XMLTYPE;
The XMLTYPE which contains the document in the specified language
For example, for doc =
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="fr">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>
TRANSLATEXML (doc, 'fr') will return:
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="fr">
Security Class Example - FR
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>
This function updates the translation in a particular language at the specified XPATH.
DBMS_XMLTRANSLATIONS.UPDATETRANSLATION( doc IN XMLTYPE, xpath IN VARCHAR2, lang IN VARCHAR2, value IN VARCHAR2, namespace IN VARCHAR2 := NULL) RETURN XMLTYPE;
Table 178-7 UPDATETRANSLATION Function Parameters
| Parameter | Description |
|---|---|
|
|
|
|
|
|
|
|
Language for which the translation is to be updated |
|
|
New translation |
|
|
Namespace |
The updated document
For example,
updateTranslation ( doc, '/securityClass/title/text()', 'fr', 'Oracle' );
produces
<securityClass xmlns="http://xmlns.oracle.com/xdb/security.xsd"
xmlns:is="xmlns.oracle.com/iStore"
xmlns:oa="xmlns.oracle.com/OracleApps"
targetNamespace="xmlns.oracle.com/example">
<name>
securityClassExample
</name>
<title xml:lang="en" xdb:srclang="true">
Security Class Example
</title>
<title xml:lang="fr">
Oracle
</title>
<inherits-from>is:iStorePurchaseOrder</inherits-from>
</securityClass>