xsl:select אם תנאי של attribute?

xsl:select אם תנאי של attribute?

אני מנסה לבחור NODEים מסוימים ב XSL (כלומר בselect של xsl:for-each) עם תנאי שבודק את attribute ולא אלמנט בן. הממ... ניסוח זוועה. אני אדגים:
<root> <elm id="1"> <childelm1>blah</childelm1> <childelm2>blah</childelm2> </elm> <elm id="2"> <childelm1>blah</childelm1> <childelm2>blah</childelm2> </elm> </root>​
אני יודע שבשביל לבחור עפ"י תוכן של אלמנט-בן אני יכול לכתוב ככה:
xsl:for-each select="root/elm[childeslm1=´blah´]"​
אבל אני רוצה לבחור עפ"י ה ID - שהוא attribute. ניסיתי פשוט לכתוב אותו כמו שכתבתי אלמנט אבל זה לא עבד. אז איך עושים את זה?
 

Lard

New member
תנסה את זה

<xsl:template match="/"> <xsl:for-each select="//elm[@id=´1´]"> <xsl:call-template name="print"/> </xsl:for-each> </xsl:template> <xsl:template name="print"> <xsl:value-of select="."/> </xsl:template>​
 
למעלה