1

こんにちは私は以下に示すxslt構造を持っています

<xsl:template name="ConvertCriticalFlags">
<xsl:param name="src1"/>
<xsl:param name="src2"/>
<xsl:param name="src3"/>
<xsl:param name="src4"/>
<xsl:param name="src5"/>
<xsl:variable name="rslt" select="''"/>
<xsl:choose>
  <xsl:when test="$src1 = 'YES'" >
    <xsl:copy-of select="concat($rslt,',', '2TO4UNITS')"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="''"/>
  </xsl:otherwise>
</xsl:choose>
<xsl:choose>
  <xsl:when test="$src2 = 'YES'">
    <xsl:copy-of select="concat($rslt,',', 'COMMERCIAL')"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="''"/>
  </xsl:otherwise>
</xsl:choose>
<xsl:choose>
  <xsl:when test="$src3 = 'YES'">
    <xsl:copy-of select="concat($rslt,',', 'ACREAGE')"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="''"/>
  </xsl:otherwise>
</xsl:choose>
<xsl:choose>
  <xsl:when test="$src4 = 'YES'">
    <xsl:copy-of select="concat($rslt,',', 'MOBILEHOME')"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="''"/>
  </xsl:otherwise>
</xsl:choose>
<xsl:choose>
  <xsl:when test="$src5 = 'YES'">
    <xsl:copy-of select="concat($rslt,',', 'VACANTLAND')"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="''"/>
  </xsl:otherwise>
</xsl:choose>
<xsl:choose>
  <xsl:when test="starts-with($rslt,',') = true">
    <xsl:copy-of select="substring($rslt,2)"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="$rslt"/>
  </xsl:otherwise>
</xsl:choose>

すべてのデータを1つの変数に連結したいのです$rsltが、できません。連結する方法を提案できますか。

4

4 に答える 4

3
<xsl:variable name="rslt" select="string-join((
  '2TO4UNITS'[$src1 = 'YES'],
  'COMMERCIAL'[$src2 = 'YES'],
  'ACREAGE'[$src3 = 'YES'],
  'MOBILEHOME'[$src4 = 'YES'],
  'VACANTLAND'[$src5 = 'YES']), ',')"/>
于 2012-08-10T17:09:28.010 に答える
2
<xsl:template name="ConvertCriticalFlags">
<xsl:param name="src1"/>
<xsl:param name="src2"/>
<xsl:param name="src3"/>
<xsl:param name="src4"/>
<xsl:param name="src5"/>
<xsl:variable name="rslt">
  <xsl:if test="$src1 = 'YES'">,2TO4UNITS</xsl:if>
  <xsl:if test="$src2 = 'YES'">,COMMERCIAL</xsl:if>
  <xsl:if test="$src3 = 'YES'">,ACREAGE</xsl:if>
  <xsl:if test="$src4 = 'YES'">,MOBILEHOME</xsl:if>
  <xsl:if test="$src5 = 'YES'">,VACANTLAND</xsl:if>
</xsl:variable>
<xsl:choose>
  <xsl:when test="starts-with($rslt,',')">
    <xsl:copy-of select="substring($rslt,2)"/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:copy-of select="$rslt"/>
  </xsl:otherwise>
</xsl:choose>
</xsl:template>
于 2012-08-10T08:29:02.880 に答える
0

XSLT 2.0でノードのシーケンスを変数にキャプチャするには、次の形式を使用します...

<xsl:variable name="rslt">
 ... sequence constructors go here..
<xsl:variable>

...フォームの代わりに..。

<xsl:variable name="rslt" select="bla bla bla" />
于 2012-08-10T08:19:59.607 に答える
-2

すべての結果を保持するサイド1変数ですべての選択条件を定義します。

于 2016-07-28T12:55:03.727 に答える