DBMS_XMLTRANSLATIONSパッケージでは、文字列を様々な言語で検索または表示できるように変換を行うためのインタフェースを提供しています。
|
関連項目: 詳細は、『Oracle XML DB開発者ガイド』を参照してください。 |
この章では、次の項目について説明します。
表163-1 DBMS_XMLSTOREパッケージのサブプログラム
| メソッド | 説明 |
|---|---|
|
|
ベース・ドキュメントでセッションの言語値を無視して問合せまたは取得が行われるように、現行のセッションの変換を無効にします。 |
|
|
現行のセッションで変換を有効にします。 |
|
|
|
|
|
すべての変換を含むベース・ドキュメントを戻します。 |
|
|
|
|
|
ソース言語を、指定したXPATHの特定の言語に設定します。 |
|
|
指定した言語でドキュメントを戻します。 |
|
|
指定した |
このプロシージャは、ベース・ドキュメントでセッションの言語値を無視して問合せまたは取得が行われるように、現行セッションの変換を無効にします。
構文
DBMS_XMLTRANSLATIONS.DISABLETRANSLATION;
このプロシージャは、現行のセッションで変換を有効にします。この動作はデフォルトです。
構文
DBMS_XMLTRANSLATIONS.ENABLETRANSLATION;
このファンクションおよびプロシージャは、XMLTYPEまたはXDBリポジトリのリソースのいずれかから、XLIFF形式で変換を抽出します。
構文
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;
パラメータ
表163-2 EXTRACTXLIFFファンクションのパラメータ
| パラメータ | 説明 |
|---|---|
|
|
|
|
|
変換を必要とする要素の位置を指定する |
|
|
名前空間。 |
|
|
|
戻り値
XLIFF形式の変換。
例
XMLTYPEからの変換の抽出
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>
xpathを = '/securityClass/title'とします。EXTRACTXLIFFの出力は次のようになります。
<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>
リソースからの変換の抽出
リソース'/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>
XPATH = ''とすると、抽出されたXLIFFは、次のようになります。
<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>
このファンクションは、すべての変換を含むベース・ドキュメントを戻します。
構文
DBMS_XMLTRANSLATIONS.GETBASEDOCUMENT( doc IN XMLTYPE) RETURN XMLTYPE;
パラメータ
戻り値
すべての変換があるベース・ドキュメントを含むXMLTYPE。
例
たとえば、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>
前述のドキュメントでは、このサブプログラムは次を戻します。
<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>
このファンクションは、XMLTYPEまたはXDBリポジトリのリソースのいずれかへ、XLIFF形式で変換をマージします。
構文
DBMS_XMLTRANSLATIONS.MERGEXLIFF( doc IN XMLTYPE, xliff IN XMLTYPE) RETURN XMLTYPE;
DBMS_XMLTRANSLATIONS.MERGEXLIFF( xliff IN XMLTYPE);
パラメータ
戻り値
'xpath'で'xliff'を'doc'にマージした結果。
例
変換のXMLTYPEへのマージ
次の入力する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>
入力するXLIFFを次のようにします。
<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>
マージの出力は次のようになります。
<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>
XLIFF変換のリソースへのマージ
前述の例の入力されたドキュメントが'/public/security.xml'のリポジトリに格納された場合、前述のXLIFFのマージによって同じ効果が得られます。
このファンクションは、ソース言語を、指定したXPATHの特定の言語に設定します。
構文
DBMS_XMLTRANSLATIONS.SETSOURCELANG ( doc IN XMLTYPE, xpath IN VARCHAR2, lang IN VARCHAR2, namespace IN VARCHAR2 := NULL) RETURN XMLTYPE;
パラメータ
表163-5 SETSOURCELANGファンクションのパラメータ
| パラメータ | 説明 |
|---|---|
|
|
ソース言語を設定する |
|
|
ソース言語を設定する |
|
|
ソース言語。 |
|
|
名前空間。 |
戻り値
更新されたドキュメント。
例
たとえば、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>
次の文の場合、
setSourceLang ( doc, '/securityClass/title', 'fr' )
次のものを生成します。
<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>
このファンクションは、指定した言語でドキュメントを戻します。
構文
DBMS_XMLTRANSLATIONS.TRANSLATEXML( doc IN XMLTYPE, lang IN VARCHAR2) RETURN XMLTYPE;
パラメータ
戻り値
指定した言語のドキュメントを含むXMLTYPE。
例
たとえば、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')は次を戻します。
<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>
このファンクションは、指定したXPATHの特定の言語で変換を更新します。
構文
DBMS_XMLTRANSLATIONS.UPDATETRANSLATION( doc IN XMLTYPE, xpath IN VARCHAR2, lang IN VARCHAR2, value IN VARCHAR2, namespace IN VARCHAR2 := NULL) RETURN XMLTYPE;
パラメータ
表163-7 UPDATETRANSLATIONファンクションのパラメータ
| パラメータ | 説明 |
|---|---|
|
|
変換を更新する |
|
|
変換を更新する |
|
|
変換を更新する言語。 |
|
|
新しい変換。 |
|
|
名前空間。 |
戻り値
更新されたドキュメント。
例
次に例を示します。
updateTranslation ( doc, '/securityClass/title/text()', 'fr', 'Oracle' );
次のものを生成します。
<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>