유틸리티 가져오기

XPath (TMS)

컨텐츠는 영어 텍스트를 Phrase Language AI를 이용해 기계 번역한 것입니다.

XPath는 XML 경로 언어를 의미합니다. XML 문서의 요소와 속성을 탐색하는 데 사용할 수 있습니다. XPATH에 처음이라면 먼저 XPath 튜토리얼을 보고 공식 XPATH 문서를 공부하세요.

AI 챗봇은 Xpath를 생성하고 검증하는 데 매우 효과적일 수 있습니다.

다음과 같은 제한 사항이 있는 XPath 1.0의 하위 집합이 지원됩니다:

  • 단계의 축

    • 지원

      조상, 조상 또는 자기 자신, 속성, 하위 요소, 자손, 자손 또는 자기 자신

    • 지원 불가

      후속, 이전, 후속 형제, 이전 형제, 네임스페이스

  • 조건부

    • 지원

      현재 노드 또는 조상 노드와 그 속성(속성, 네임스페이스)에 대한 조건

    • 지원 불가 (예:)

      위치 번호, 축 child::, 자손, 자손 또는 자기 자신, following::, preceding::, following-sibling::, preceding-sibling::, 함수 last()

기본 규칙

  • 경로에서 ///를 사용하세요

  • 이름에 단일 인용부호 ' '를 사용하세요

  • 요청을 결합하기 위해 파이프 |를 사용하세요

  • 이름은 대소문자를 구분합니다: <Body><body>와 다릅니다.

예:

XPath 예제 1 및 XPath 예제 2 (네임스페이스 포함)은 다음을 위한 예제 파일입니다:

  1. 모든 요소와 모든 속성을 가져오기

    //* | //@*

  2. 모든 요소와 속성1의 값을 가져오기

    (<elem1 attribute1="translate" attribute2="번역하지 마세요"/>)

    //* | //@attribute1

  3. Child 요소의 모든 자손 가져오기

    //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의 값 가져오기

    <Data Text="번역할 텍스트">

    //data/@text

  7. 요소 <mT:translation>과 그 자손을 가져오되 요소 <mT:ignore>는 제외

    //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. 그들 또는 그 조상이 'link'를 포함하는 속성 '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"><Child><Text>translate this</Text></Child>

    • <Child>의 모든 요소를 가져옵니다:

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

    • <Child><Text> 요소만 가져옵니다:

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

    • <ORIGINAL>의 값이 <CONTRACT><CATEGORY> 속성에 있는 경우, <CONTRACT> 요소 아래의 모든 요소를 가져옵니다.

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

  16. 네임스페이스 및 속성이 있는 XML <root> xmlns:xhtml="http://www.w3.org/1999/xhtml"<Child translate='1'>이것을 번역하세요</Child>

    • 속성 translate가 1인 경우 <Child> 요소를 가져옵니다: //*[local-name()="Child"][@*[local-name()='translate']='1']

    • 속성 translate=true인 모든 요소를 가져옵니다: //*[@*[local-name()='translate']='true']

  17. 네임스페이스가 있는 XML. 요소 tu에서 요소 target을 가져오되, 속성 id에 'img' 또는 'extra'가 포함된 경우는 제외합니다:

    1. 파일 예시:

      <tu id="pages|content|extra"><ori xml:lang="en">코스 하나</ori><target xml:lang="lang">코스 하나</target></tu>

    2. XPATH 예시:

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

  18. <comment><lis>를 제외한 모든 요소를 가져오되, <lis translate="true"> 및 그 하위 요소는 제외하지 않습니다:

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

  19. 모든 요소를 가져오되 <comment> 및 속성이 <... attribute2="Do not translate">인 요소와 그 자손은 제외합니다:

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

  20. 속성 varNameglossName의 값을 가져오되, 그 조상이 속성 attribute1='translate' 또는 attribute1='edit'를 가지고 있는 경우에만 가져옵니다:

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

  21. 속성이 Name= Back, Menu, 또는 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인 모든 요소를 잠급니다: Back, Menu, 또는 Time 및 그 자손:

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

    2. 값이 Name인 모든 속성을 잠급니다: Back, Menu, 또는 Time 및 그 자손

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

일부 외부 예시.

컨텍스트 메모

컨텍스트 메모는 번역된 세그먼트에 가져올 수 있습니다.

이 샘플에는 세 가지 예가 있습니다:

<?xml version-"1.0" encoding="utf-8"?>
<root>
<element context1="부모 요소 1의 속성에 있는 메모 - 선택 ../@context1">
<field context2="속성 1에 있는 메모 - 선택 @context2" >for translation1</field>
<context3>요소 1의 메모 - 선택 ../context3</context3>
</element>

<element context1="부모 요소 2의 속성에 있는 메모">
<field context2="속성 2에 있는 메모">for translation2</field>
<context3>요소 2의 메모</context3>
</element>

</root>
  • 부모 요소의 속성 (컨텍스트 1): ../@context1

  • 자기 요소의 속성 (컨텍스트 2): @context2

  • 형제 요소 (컨텍스트 3): ../context3

가져오기 요소 및 속성: //*의 경우, 컨텍스트 메모의 내용이 소스 세그먼트로 가져와질 것입니다. 요소 및 속성의 일반 가져오기에서 컨텍스트 메모 요소/속성을 제외하십시오.

도움이 되었습니까?

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.