입력 XML
1 2 3 4 5 6 7 8 9 10 |
<Booking> <HtlSegOptFlds> <HotelName>Grand Plaza</HotelName> </HtlSegOptFlds> <HtlSegOptFlds> <HotelName>Sunset Resort</HotelName> </HtlSegOptFlds> </Booking> |
XSLT 스타일시트
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <!-- HtlSegOptFlds 요소에 매치하는 템플릿 --> <xsl:template match="HtlSegOptFlds"> <Hotel> <xsl:copy-of select="HotelName"/> </Hotel> </xsl:template> <!-- 나머지 노드 처리 --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> |
변환 결과
1 2 3 4 5 6 7 8 9 10 |
<Booking> <Hotel> <HotelName>Grand Plaza</HotelName> </Hotel> <Hotel> <HotelName>Sunset Resort</HotelName> </Hotel> </Booking> |