インポートユーティリティ

XPath (TMS)

本コンテンツはPhrase Language AIの機械翻訳により、英語から翻訳されています。

XPathはXMLパス言語の略です。XML ドキュメント内の要素や属性をナビゲートするために使用できます。XPATHを初めて使用する場合は、 XPath Tutorial を最初に参照し、公式の XPATHドキュメントを確認してください。

AIチャットボットは、Xpathの生成と検証に非常に効果的です。

XPath 1.0のサブセットは、次の制限付きでサポートされています。

  • ステップ内の軸

    • サポート

      祖先、祖先自身、属性、子、子孫、子孫自身

    • サポートなし

      後続、先行、後続兄弟、先行兄弟、名前空間

  • 述語

    • サポート

      現在のノードまたは先祖ノードの条件とそのプロパティ(属性、名前空間)

    • サポートされていない(例)

      position number, axis 子::, descendant, descendant-or-self, following::, preceding::, following-sibling::, previous-sibling::, function last()

基本ルール

  • パスで///を使用

  • 名前に一重引用符「」を使用

  • パイプを使用 | リクエストを結合する

  • 名前の大文字と小文字は区別されます。<本文><本文>とは異なります

XPath 例 1 と XPath 例 2 (名前空間あり)は、次のファイルの例です。

  1. すべての要素とすべての属性をインポート

    //* | //@*

  2. すべての要素とattribute1の値をインポート

    (<elem1 attribute1="translate" attribute2="翻訳しない"/>)

    //* | //@attribute1

  3. 子要素のすべての子をインポート

    //Child//*

  4. 属性 translate='true' の場合のみ、要素 lis とその子孫をインポート 

    (<lis translate="true">これを翻訳</lis><lis translate="false">翻訳しない</lis>)

    //lis[@translate='true']/descendant-or-self::*

  5. 要素の属性が translate='true' の場合、すべての要素とサブフォルダをインポート

    //*[@translate='true']/descendant-or-self::*

  6. 属性「テキスト」の値を「データ」にインポート

    <Data Text="Text for translation">

    //data/@text

  7. <mT:translation> 要素とその子孫要素(<mT:無視> 要素を除く)をインポート

    //mT:translation/descendant-or-self::*[not(ancestor-or-self::mT:ignore)]

  8. translate='false'属性を持つすべての要素を除外

    //*[not(@translate='false')]

  9. translate='false'属性で要素'lis'を除外

    (<lis translate="false">翻訳しない)

    //*[not(self::lis[@translate='false'])]

  10. translate='false' 属性を持つ要素 'lis' とその下位要素を除外

    (<lis translate="false"><p>翻訳しない)

    //*[not(ancestor-or-self::lis[@translate='false'])]

  11. 'link'を含むすべての要素を除外

    (<menu1link><tmenu41link>)

    //*[not(contains(name(),'link'))]

  12. 要素またはその祖先に「リンク」を含む属性「lis」がある場合、すべての要素を除外

    (<ele lis=menu1link>, <mon lis=tmenu41link>)

    //*[not(ancestor-or-self::node()[contains(@lis, 'link')])]

  13. 親 LANG に 2015 年の「更新済」属性がある場合、PT 要素をインポート

    (<LANG updated="20150213T121526"><PT>'

    //LANG[contains(@updated,'2015')]/PT

  14. インポート要素'説明'と'名前'は、要素'定義'または'タイプ'の子孫でない場合にのみインポート

    ://*[not(ancestor-or-self::*[(name()='Definitions') or (name()='Types')]]/*

    [(name()='Description') or (name()='Name')]

  15. 名前空間付きXML

    <root xmlns:xhtml="http://www.w3.org/1999/xhtml"><子><テキスト>これを翻訳</テキスト></子>

    • <子>のすべての要素をインポート:

      //*[local-name()='Child']//*

    • <子>内の<テキスト>要素のみをインポート:

      //*[local-name()='Child']/*[local-name()='Text']

    • <CONTRACT> 内の属性 <CATEGORY> の値が <ORIGINAL> である場合、<CONTRACT> 内のすべての要素をインポート

      ://*[local-name()='CONTRACT' and @CATEGORY='ORIGINAL']://*

  16. 名前空間と属性を持つXML <root> xmlns:xhtml="http://www.w3.org/1999/xhtml"<子 translate='1'>これを翻訳</子>

    • インポート要素 <子> (translate 属性が 1: の場合) //*[local-name()="子"][@*[local-name()='translate']='1']

    • translate=true: //*[@*[local-name()='translate']='true']属性を持つすべての要素をインポートする

  17. 名前空間付きのXML。要素訳文を要素tuからインポートします。ただし、属性IDに「img」または「extra」が含まれている場合はインポートできません。

    1. ファイルの例:

      <tu ID="pages|コンテンツ|extra"><ori xml:lang="en">1コース</ori><訳文 xml:lang="lang">1コース</訳文></tu>

    2. XPATHの例:

      //*[local-name()='tu' and not(contains(@id,'img') or contains(@id,'extra'))]/*[local-name()='訳文']

  18. <コメント><lis>を除くすべての要素をインポート(<lis translate="true">とその子孫を除く):

    //*[count(ancestor-or-self::node()[(name()='lis' and (not(@translate='true'))) ) or name()='コメント']]=0]

  19. <コメント>を除くすべての要素、および属性 <... attribute2="Do not translate"> を持つ要素とその子孫を除くすべての要素をインポート:

    //*[count(ancestor-or-self::node()[(@attribute2='Do not translate') or name()='comment'])=0]

  20. 属性 varNameglossName の値をインポートします。ただし、祖先に属性 attribute1='translate' または attribute1='編集' がある場合のみです。

    //*[(self::node()[@attribute1='translate' or @attribute1='編集']]]//@*[local-name()='varName' or local-name()='glossName']

  21. Name= BackMenu、またはTime属性を持つ要素を除くすべての要素と属性をインポート:

    //*[not(ancestor-or-self::node()[@Name='Back' or @Name='Menu' or @Name='Time']]] | //@*[not(ancestor-or-self::node()[@Name='Back' or @Name='Menu' or @Name='Time']]]

    この場合は、すべてインポートし、インポートに不要な属性をロックした方が良い場合があります。セグメントがロック済になったら、エディタで訳文に原文をコピーし、オーダー通りに翻訳を進めます。

    1. 属性 Name を持つすべての要素を値でロックする:戻るメニュー時間とその子孫:

      //*[@Name='Back' or @Name='Menu' or @Name='Time']/descendant-or-self::*

    2. Nameのすべての属性を値でロックする:戻るメニュー時間とその子孫

      //*[@Name='Back' or @Name='Menu' or @Name='Time']//@*

外部 の例

コンテキストメモ

コンテキストノートは翻訳済セグメントにインポートできます。

このサンプルには3つの例があります。

<?xml version-"1.0" encoding="utf-8"?>
<root>
<element context1="parentElement 1 の属性のメモ - ../@context1 を選択">
<field context2="属性1の備考 - @context2">翻訳1を選択</field>
<context3>要素1の注 - ../context3を選択</context3>
</element>

<element context1="parentElement 2の属性内の注">
<field context2="属性2の備考">翻訳2</field>
<context3>要素2の注</context3>
</element>

</root>
  • 親素(コンテキスト1)の属性: ../@context1

  • 自己要素(context2)の属性:@context2

  • 兄弟要素(コンテキスト3): ../context3

Elements&Attributes://* をインポートする場合、コンテキストメモのコンテンツは原文セグメントにもインポートされます。Elements&Attributesの一般的なインポートからコンテキストメモの要素/属性を除外します。

この記事は役に立ちましたか?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.