사용자 도구

사이트 도구


groovy:xml

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
groovy:xml [2017/12/20 17:21]
kwon37xi [XML Builder]
groovy:xml [2017/12/27 08:29]
kwon37xi [XML Builder]
줄 22: 줄 22:
   * ''MarkupBuilder''   * ''MarkupBuilder''
   * ''StreamingMarkupBuilder'' : ''mkp''를 통해 각종 설정 가능.   * ''StreamingMarkupBuilder'' : ''mkp''를 통해 각종 설정 가능.
-  * [[https://stackoverflow.com/questions/11388838/groovy-markupbuilder-name-conflict/11389034#11389034|Groovy MarkupBuilder name conflict]] 생성할 XML 태그 이름이 이미 Groovy Object에 존재하는 메소드 이름일 경우 충돌 해결<code groovy>+  * [[https://stackoverflow.com/questions/11388838/groovy-markupbuilder-name-conflict/11389034#11389034|Groovy MarkupBuilder name conflict]] 생성할 XML 태그 이름이 이미 Groovy Object에 존재하는 메소드 이름일 경우 충돌 해결 conflict<code groovy>
 // <identity>....</identity> // <identity>....</identity>
 identity([:]) { identity([:]) {
줄 30: 줄 30:
 } }
 // 뒤에 ([:]) 로 호출하여 다른 메소드 시그너처로 바꿔치기함 // 뒤에 ([:]) 로 호출하여 다른 메소드 시그너처로 바꿔치기함
 +</code>
 +  * 혹은 ''delegate.tagname'' 으로 충돌해소 가능 [[http://mrhaki.blogspot.kr/2012/01/groovy-goodness-solve-naming-conflicts.html|Groovy Goodness: Solve Naming Conflicts with Builders]] <code groovy>
 +def builder = new MarkupBuilder(writer)
 +builder.message {
 +    delegate.body(contentType: 'plain') {
 +        text 'Simple message'
 +    }
 +}
 +// -->
 +<message>
 +  <body contentType='plain'>
 +    <text>Simple message</text>
 +  </body>
 +</message>
 </code> </code>
 ===== Pretty Print ===== ===== Pretty Print =====
groovy/xml.txt · 마지막으로 수정됨: 2017/12/27 08:29 저자 kwon37xi