xslt
xslt의 변수
수색…
XSLT 변수
전역 변수 : 이 변수는 xsl 스타일 시트의 모든 곳에서 사용할 수 있습니다. 이 변수는 <xsl : stylesheet> 요소의 자식이어야합니다.
로컬 변수 : 이 변수는 선언 된 위치에서만 사용할 수 있습니다.
아래 코드 참조 :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:variable name="a" select="5"/> <!-- Global Variable -->
<xsl:template match="/">
<xsl:variable name="b" select="2"/> <!--Local Variable -->
<xsl:value-of select="$a+$b"/> <!--Addition of 'a' and 'b' -->
</xsl:template>
</xsl:stylesheet>
위의 코드의 출력은 다음과 같습니다 (7)
다음과 같이 변수에 값을 정의하는 두 가지 방법이 있습니다.
<xsl : variable> 요소 의 @select 속성 에서 xpath 표현식으로 :
<xsl:variable name="apple" select="'RED'"/>
또는
<xsl : variable> 요소 의 내용은 다음 과 같습니다.
<xsl:variable name="apple">RED</xsl:variable>
선언 된 변수를 호출하려면 위의 코드 '$ a'와 같이 변수 이름과 함께 $ Sign을 사용하십시오.
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow