Remark : concat
XSLT의 concat 함수는 여러 문자열을 결합하는 데 사용되며, 이론적으로는 매개변수의 수에 제한이 없습니다. 즉, 필요한 만큼 많은 문자열을 전달할 수 있습니다. 그러나 실제 사용 가능한 매개변수의 수는 처리하는 XSLT 프로세서의 구현에 따라 다를 수 있습니다. 일반적으로는 여러 개의 문자열을 매우 효율적으로 결합할 수 있습니다.
예제1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <!-- `FldAry` 내의 모든 요소를 처리 --> <xsl:template match="FldAry"> <!-- 성(Last Name)을 추출 --> <xsl:variable name="LastName" select="Fld[ID='NL']/Contents"/> <!-- 이름(First Name)을 추출 --> <xsl:variable name="FirstName" select="Fld[ID='NF']/Contents"/> <!-- 성과 이름을 한 줄에 출력 --> <xsl:value-of select="concat($LastName, ' ', $FirstName)"/> </xsl:template> </xsl:stylesheet> |
1 2 3 4 5 6 |
<xsl:value-of select="concat('length: ',string-length(.))" /> => length:20 |
예제2
1 2 3 4 5 6 7 |
<Person> <FirstName>John</FirstName> <MiddleName>Quincy</MiddleName> <LastName>Adams</LastName> </Person> |
1 2 3 4 5 6 7 |
<xsl:template match="Person"> <FullName> <xsl:value-of select="concat($LastName, ', ', $FirstName, ' ', $MiddleName)" /> </FullName> </xsl:template> |
1 2 3 |
Adams, John Quincy |