- - PR -
XSLでの集約の方法を教えて下さい
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2003-05-30 20:51
・xml
<root> <data syainno='1' jigyousyo='東京' eigyousyo='新宿'> <data syainno='2' jigyousyo='東京' eigyousyo='渋谷'> <data syainno='3' jigyousyo='東京' eigyousyo='新宿'> <data syainno='4' jigyousyo='大阪' eigyousyo='梅田'> </root> 上記のXML文書からjigyousyo='東京'のユニークなeigyousyo(新宿、渋谷)を 抽出したいのですが、 ・xsl1 <xsl:template match="data"> <xsl:if test="not(preceding::data[@eigyousyo = current()/@eigyousyo and @jigyousyo='東京'])"> <xsl:value-of select="@eigyousyo" /> </xsl:if> </xsl:template> では、期待通りの結果が得られません。 ちなみに、 ・xsl2 <xsl:template match="data[@jigyousyo='東京']/@eigyousyo"> <xsl:if test="not(preceding::Data/@eigyousyo[. = current()])"> <xsl:value-of select="." /> </xsl:if> </xsl:template> とすると期待通りの結果が得られるのですが、将来的に'東京'を変数に 置き換えたいのでありまして、実際、変数に置き換えるとエラーが出て しまいます。よって現在、xsl1の方向で進めています。 以上、どなたか御教授お願いいたします。 [ メッセージ編集済み 編集者: 匿名M 編集日時 2003-05-30 20:52 ] |
|
投稿日時: 2003-05-31 16:57
・xsl1
<xsl:template match="data"> <xsl:if test="not(preceding::data[@eigyousyo = current()/@eigyousyo]) and @jigyousyo='東京'"> <xsl:value-of select="@eigyousyo" /> </xsl:if> </xsl:template> で解決しました。 |
1