我正在嘗試從我的xml文檔中提取特定節點,但繼續從所有節點獲取內容。我正在測試一個特定的jNumber,通過將該數字傳遞給使用片段調用($ jNumber)設置的變量中的xslt。僅從一個節點提取內容
<xsl:if test="products/product/jNumber[. = $jNumber]">
<div class="floatLeft padTop10 margLeft10" style="width:185px;">
<xsl:for-each select="products/product/topicFocus">
<div id="tab{./@tab}focus" class="linksUnit padBtm3" style="display:block;"><xsl:text>» </xsl:text><a href="#" class="bold" target="_blank"><em><xsl:value-of select="./@name" /></em></a></div>
<div id="tab{./@tab}ready" class="linksUnit padBtm3" style="display:none;"><xsl:text>» </xsl:text><a href="#" target="_blank"><xsl:value-of select="./@name" /></a></div>
</xsl:for-each>
<xsl:for-each select="products/product/topicLeft">
<div id="tab{./@tab}focus" class="linksUnit padBtm3" style="display:none;"><xsl:text>» </xsl:text> <a href="#" class="bold" target="_blank"><em><xsl:value-of select="./@name" /></em></a></div>
<div id="tab{./@tab}ready" class="linksUnit padBtm3" style="display:block;"><xsl:text>» </xsl:text><a href="#" target="_blank"><xsl:value-of select="./@name" /></a></div>
</xsl:for-each>
</div>
</xsl:if>
這是我的理解是,if語句只會導致測試真正的節點被顯示。真的嗎?
<products>
<product>
<jNumber>1234</jNumber>
<name>Product #1</name>
<numberoftabs>12</numberoftabs>
<!-- Links at top of the page -->
<topicFocus tab="1" name="Accessories"></topicFocus>
<!--topicLeft tab="2" name="Configuration examples"></topicLeft-->
<topicLeft tab="2" name="Resources (white papers, datasheets, etc.)"></topicLeft>
<topicLeft tab="3" name="Download software"></topicLeft>
<topicLeft tab="4" name="FAQs"></topicLeft>
<topicLeft tab="5" name="Interoperability"></topicLeft>
<!--topicLeft tab="6" name="MIBs"></topicLeft-->
<topicRight tab="6" name="Technical documentation">
<subCategory tab="7">Management and Configuration</subCategory>
<subCategory tab="8">Archived</subCategory>
</topicRight>
<topicRight tab="9" name="Related links"></topicRight>
<topicRight tab="10" name="Support form"></topicRight>
</product>
</products>