2
나는 얼마나 많은 SIM 카드를 같은 사람이 구입했는지 알아 내고 그 번호를 고객 ID와 함께 출력하는 XSL 파일을 작성하려고합니다. 여기 XSL : 특정 값의 각 인스턴스를 찾기 위해 카운트 사용
은 관련 태그의 예와 XML 파일의 추출물이다 :<sim>
<simID>16</simID>
<areaCode>081</areaCode>
<number>1234582</number>
<customerID>5</customerID>
<yearPurchased>2008</yearPurchased>
<monthPurchased>10</monthPurchased>
<dayPurchsed>12</dayPurchsed>
</sim>
<customer>
<customerID>5</customerID>
<surname>Brown</surname>
<firstname>Peter</firstname>
<streetAddress>103 Main Street</streetAddress>
<townName>Dorpborough</townName>
<countyName>Kilkenny</countyName>
<contractOrPrepaid>contract</contractOrPrepaid>
<confirmedIdentity>1</confirmedIdentity>
</customer>
<sims>
및 <customers>
는 여기 태그 내에서 해당 태그의 여러 인스턴스, 같은 아이들과 함께 모두있다 내 XSL 코드 :
<table rules="all">
<thead>
<tr>
<th>Customer ID</th>
<th>No. of Sims Purchased</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="database/customers/customer">
<xsl:variable name="customerIDvar" select="customerID"/>
<xsl:variable name="numOfSims">
<xsl:for-each select="database/sims/sim">
<xsl:value-of select="count([customerID=$customerIDvar])">
</xsl:for-each>
</xsl:variable>
<xsl:if test="$numOfSims>1">
<tr>
<td>
<xsl:value-of select="$customerIDvar"/>
</td>
<td>
<xsl:value-of select="$numOfSims"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</tbody>
</table>
정확하게 잘못하고있는 부분을 알아낼 수 없습니다. 특히 "numOfSims"변수입니다. 나는 일할 수 없다. 어떤 도움이라도 대단히 감사하겠습니다. 당신의 XML이 같은이라고 가정
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<table rules="all">
<thead>
<tr>
<th>Customer ID</th>
<th>No. of Sims Purchased</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="database/customers/customer">
<xsl:variable name="customerIDvar" select="customerID"/>
<xsl:variable name="numOfSims">
<xsl:value-of select="count(/database/sims/sim[customerID=$customerIDvar])"/>
</xsl:variable>
<xsl:if test="$numOfSims>1"><tr>
<td>
<xsl:value-of select="$customerIDvar"/>
</td>
<td>
<xsl:value-of select="$numOfSims"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</tbody>
</table>
</xsl:template>
</xsl:stylesheet>
을 :
하지 대답을하지만,해야하지 ' 1 ">'be '? –
publicgk
아마도 "> 1"이어야합니다. 그러면 청소기가됩니다. –
@publicgk 나는 최근에'>'가 탈출 할 필요가 없다는 것을 배웠다. –