1
나는이 나무/하나/차/차와 두 번째/메이커/자동차/차를 가진 나무를 가지고있다. 첫번째 것은 차의 두 번째 목록의 id에 대한 참조를 가지고있다. 두 요소가 xslt에서 같은 이름을 가질 때 어떻게 서로 연결합니까?
내가 이것을 가지고
<xsl:template match="t:cars/t:car">
<tr>
<td>
<xsl:if test="position()=1">
<b><xsl:value-of select="../@name"/><xsl:text> </xsl:text></b>
</xsl:if>
</td>
</tr>
, 그것은 내가 그것을 할 could't 조금 후에 배울 for 루프에 가득 차 있었다.
이
은 무엇인지하기 전에 :<xsl:template match="t:cars/t:car">
<tr>
<td>
<xsl:if test="position()=1">
<b><xsl:value-of select="../@name"/><xsl:text> </xsl:text></b>
</xsl:if>
<xsl:for-each select="/t:root/t:maker/t:car">
<xsl:if test="t:root/t:maker/@id = @ref">
<xsl:value-of select="@title"/>
</xsl:if>
</xsl:for-each>
</td>
</tr>
샘플 :
auto>
<maker type="toyota">
<car name="prius" id="1"/>
</maker>
<cars name="My Collection">
<car ref="1" />
</cars>
샘플 입력 및 필수 출력 xml을 사용하면 문제를 훨씬 쉽게 이해할 수 있습니다. – Kevan