[英]Determine parent-parent template in xslt
我有一個問題,我需要根據父父模板對模板進行一些更改。 在此示例中,如果父模板為Debtor
則PhysicalPerson
模板為Ok,但如果Claimant
為模板,則PhysicalPerson
為OK。 而且所有的區別是,一個名稱中需要Name,而另一個名稱中不需要Name,還要鏈接<a class="UserDataButton" style="float:right; padding:2px 2px 0 0;">Insert my data</a>
我需要第一但不需要第二。
甚至可以確定標簽是否屬於特定的父/母模板? 還是我需要不同的方法?
<xsl:template match="t:Debtor">
<div class="tab-pane" id="tab-Debtor" data-tab-name="Debtor">
<xsl:apply-templates select="t:PhysicalPerson" />
<xsl:apply-templates select="t:LegalPerson" />
<xsl:apply-templates select="t:AddressList" />
<xsl:apply-templates select="t:PhoneList" />
<xsl:apply-templates select="t:EmailList" />
</div>
</xsl:template>
<xsl:template match="t:Claimant">
<div class="tab-pane" id="tab-Claimant" data-tab-name="Claimant">
<xsl:apply-templates select="t:PhysicalPerson" />
<xsl:apply-templates select="t:LegalPerson" />
<xsl:apply-templates select="t:AddressList" />
<xsl:apply-templates select="t:PhoneList" />
<xsl:apply-templates select="t:EmailList" />
</div>
</xsl:template>
<xsl:template match="t:PhysicalPerson">
<div>
<div class="fiz_persona">
<div style="float:left; padding:2px 0 0 2px;">
Physical Person
</div>
<a class="UserDataButton" style="float:right; padding:2px 2px 0 0;">
Insert my data
</a>
<br />
<label class="floatleft required"><span class="star">*</span>
Name
</label>
...................
如果使用<xsl:template match="t:Debtor/t:PhysicalPerson">
則該模板僅應用於具有t:Debtor
父元素的t:PhysicalPerson
元素。 然后,您可以編寫另一個模板<xsl:template match="t:Claimant/t:PhysicalPerson">...</xsl:template>
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.