Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

XML 문자열을 스키마로 해석

항목값
화면 이름Parse XML as schema
식별자parseXmlAsSchemaV2
지원 실행 방식Batch, Streaming
범주파일 (File), 구조체 (Struct)
반환 자료형Struct

지정한 스키마로 XML 문자열을 해석하며 스키마에 없는 필드는 무시합니다.

입력 인자

이름지정 여부자료형의미와 조건
Input schema필수Type<Struct>XML 문자열을 해석할 스키마 정의입니다.
Xml필수Expression<String>해석할 XML 문자열입니다.
Attribute prefix선택Literal<String>태그 속성에 사용할 접두사입니다.
Ignore namespace선택Literal<Boolean>요소와 속성의 이름 공간을 무시할지 지정합니다. 예를 들어 <ns1:author ns2:attr="value" />를 <author attr="value" />처럼 처리합니다. 기본값은 false입니다.
Output mode선택Enum<Simple, With errors>simple 모드는 잘못된 입력을 포함한 파싱 오류가 발생하면 null을 반환합니다. with errors 모드는 해석한 XML을 ok, 오류를 errors 필드에 담은 구조체를 반환합니다.
Value tag선택Literal<String>자식은 없고 속성은 있는 요소에서 값에 사용할 태그입니다.

입출력 예시

예시 1: 기본 동작

인자 값:

  • Input schema: Struct<id:String, airport:Struct<id:String, miles:Integer>>
  • Xml: xml
  • Attribute prefix: null
  • Ignore namespace: null
  • Output mode: SIMPLE
  • Value tag: null
xml출력
<airline>
 <id>XB-112</id>
 <airport>
  <id>JFK</id>
  <miles>2000</miles>
 </airport>
</airline>
{
 airport: {
 id: JFK,
 miles: 2000,
},
 id: XB-112,
}

예시 2: 기본 동작

이름 공간을 무시하면 입력의 이름 공간을 제거하여 해석합니다. 따라서 스키마에 이름 공간을 포함한 키는 일치하지 않습니다.

인자 값:

  • Input schema: Struct<name:String, _attribute:String, email:String, address:Struct<nevermatches:street:String, city:String, state:String, zip:String>>
  • Xml: xml
  • Attribute prefix: _
  • Ignore namespace: true
  • Output mode: SIMPLE
  • Value tag: null
xml출력
<ns1:person ns1:attribute="tall">
<ns1:name>John Doe</ns1:name>
<email>john.doe@exampl...
{
 _attribute: tall,
 address: {
 city: Exampleville,
 *...

예시 3: null 처리

입력 XML에 요청한 필드가 없으면 해당 필드는 null입니다.

인자 값:

  • Input schema: Struct<id:String, airport:Struct<id:String, miles:Integer>>
  • Xml: xml
  • Attribute prefix: null
  • Ignore namespace: null
  • Output mode: SIMPLE
  • Value tag: null
xml출력
<airline>
 <id>XB-112</id>
 <airport>
  <id>JFK</id>
 </airport>
</airline>
{
 airport: {
 id: JFK,
 miles: null,
},
 id: XB-112,
}

예시 4: null 처리

요청한 스키마가 더 작으면 스키마에 있는 필드만 해석합니다.

인자 값:

  • Input schema: Struct<id:String>
  • Xml: xml
  • Attribute prefix: _
  • Ignore namespace: null
  • Output mode: SIMPLE
  • Value tag: null
xml출력
<airline>
 <id>XB-112</id>
 <airport>
  <id>JFK</id>
 </airport>
</airline>
{
 id: XB-112,
}

예시 5: null 처리

이름 앞에 속성 접두사를 붙여 XML 속성을 읽습니다.

인자 값:

  • Input schema: Struct<id:String, airport:Struct<_id:String, miles:Integer>>
  • Xml: xml
  • Attribute prefix: _
  • Ignore namespace: null
  • Output mode: SIMPLE
  • Value tag: null
xml출력
<airline> <id>XB-112</id> <airport id="JFK">
  <miles>2000</miles>
 </airport>
</airline>
{
 airport: {
 _id: JFK,
 miles: 2000,
},
 id: XB-112,
}

긴 구조값 안의 줄임표는 생략한 내용을 나타냅니다.