04/04/08 16:06
>>272
>1. /A/B/Cで○があるもの、もしくは○がないもの
starts-with(.,'○') か これを not() で囲う
>2. 自分の一番近い兄で/A/B/Cで○があるもの
>というのはどう表記されるでしょうか?
preceding::C[starts-with(.,'○')][1]
こんなでしょうか。ここから
<xsl:template match="/A">
<A>
<xsl:apply-templates select="B/C[starts-with(.,'○')]"/>
</A>
</xsl:template>
<xsl:template match="B/C[starts-with(.,'○')]">
<xsl:variable name="val" select="."/>
<B>
<C><xsl:value-of select="."/></C>
<xsl:for-each select="following::C[substring(.,1,1) != '○']">
<xsl:if test="preceding::C[starts-with(.,'○')][1] = $val">
<D><xsl:value-of select="."/></D>
</xsl:if>
</xsl:for-each>
</B>
</xsl:template>
これでとりあえずできるかと。要素数増えるとfor-each以下が効率悪そうだけ
ど。(.,'○')が顔文字にしか見えないのが欠点。