在XSLT中绑定Child元素 [英] Bind Child element in XSLT
本文介绍了在XSLT中绑定Child元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI,
下面是我的xml模式,现在我需要将这些xml绑定到xslt。
< 报价 >
< Quotation_Customer >
< quoteid > Quote1 < / quoteid >
< cus_name > xyz < / cus_name >
< cus_address > chennai < / cus_address >
< contact_person > yyyyyyy < / contact_person >
< Quotation_Products >
< quoteid > Quote1 < / quoteid >
< pid > PR 1 < / pid >
< product_name > aasasaaa < / product_name >
< / Quotation_Products >
< / Quotation_Customer >
< Invoice_Customer >
< cus_name > ; xyz < / cus_name >
< contact_person > abcde < / contact_person >
< / Invoice_Customer >
< ; Invoice_Customer >
< cus_name > kjkajsd < / cus_name >
< contact_ person > adf < / contact_person >
< / Invoice_Customer >
< / Quote >
XSLT
< xsl:模板 匹配 = 引用 >
< 表格 >
< xsl:apply-templates select = Quotation_Customer > < / xsl:apply-templates >
< / table >
< / xsl:template >
< xsl:template 匹配 = Quotation_Customer >
< tr >
< td >
< xsl:value-of select = quoteid / >
< / td >
< / tr >
< tr >
< td >
< xsl:value-of 选择 = cus_name / >
< / td < span class =code-keyword>>
< / tr >
< tr >
< td >
< xsl:value-of select = cus_address / >
< / td >
< / tr >
< tr >
< td >
< xsl:value-of 选择 = contact_person / >
< / td >
< / tr >
< tr >
< xsl:apply-templates 选择 = Quotation_Products > < / xsl:apply-templates >
< / tr >
< span class =code-keyword>< / xsl:template >
< xsl:template 匹配 = Quotation_Products >
< td >
< xsl: value-of 选择 = pid / > ;
< / td >
< td >
< xsl:value-of 选择 = product_name / >
< / td >
< td >
< 选择 >
< xsl:apply-templates < span class =code-attribute> select = ../ Invoice_Customer < span class =code-keyword>> < / xsl:apply-templates >
< / select >
< / td >
< / xsl:template >
< < span class =code-leadattribute> xsl:template 匹配 = Invoice_Customer >
< 选项 >
< xsl:value-of 选择 = ../ cus_name / >
< span class =code-keyword>< / option >
< / xsl:template >
来自上面的xslt的
一切正常但是选择下拉列表是n binding绑定如何匹配模板..
代码块已更正[/ edit]
解决方案
HI ,,
我自己解决了这个问题..
下面是解决方案..
< xsl:template match = Quotation_Products >
< td >
< xsl:value-of 选择 = pid / >
< / td >
< td >
< xsl:value-of select = product_name / >
< / td >
< td >
< select >
< xsl:apply-templates 选择 = parent :: node()/ parent :: node()/ Invoice_Customer > < / xsl:apply-templates >
< / select >
< / td >
< td >
< a href = #myModal data-id = {pid} 数据-campid = {quoteid} class = btn btn-primary data-toggle = modal > 续订< / a >
< 跨度> / td >
< / xsl:template >
< xsl:template 匹配 = Invoice_Customer > ;
< 选项 value = {cus_name} >
< xsl :value-of 选择 = cus_name / >
< / option > 跨度>
HI,
Below is my xml pattern, now i need to bind these xml to xslt.
<Quote>
<Quotation_Customer>
<quoteid>Quote1</quoteid>
<cus_name>xyz</cus_name>
<cus_address>chennai</cus_address>
<contact_person>yyyyyyy</contact_person>
<Quotation_Products>
<quoteid>Quote1</quoteid>
<pid>PR1</pid>
<product_name>aasasaaa</product_name>
</Quotation_Products>
</Quotation_Customer>
<Invoice_Customer>
<cus_name>xyz</cus_name>
<contact_person>abcde</contact_person>
</Invoice_Customer>
<Invoice_Customer>
<cus_name>kjkajsd</cus_name>
<contact_person>adf</contact_person>
</Invoice_Customer>
</Quote>
XSLT
<xsl:template match="Quote">
<table>
<xsl:apply-templates select="Quotation_Customer"></xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="Quotation_Customer">
<tr>
<td>
<xsl:value-of select="quoteid"/>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="cus_name"/>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="cus_address"/>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="contact_person"/>
</td>
</tr>
<tr>
<xsl:apply-templates select="Quotation_Products"></xsl:apply-templates>
</tr>
</xsl:template>
<xsl:template match="Quotation_Products">
<td>
<xsl:value-of select="pid"/>
</td>
<td>
<xsl:value-of select="product_name"/>
</td>
<td>
<select>
<xsl:apply-templates select="../Invoice_Customer"></xsl:apply-templates>
</select>
</td>
</xsl:template>
<xsl:template match="Invoice_Customer">
<option>
<xsl:value-of select="../cus_name"/>
</option>
</xsl:template>
from the above xslt everything is working fine but that select dropdown is not binding how to match the template..
[edit]Code block corrected[/edit]
解决方案
HI,,
I solved this myself..
Below is the Solution..
<xsl:template match="Quotation_Products"> <td> <xsl:value-of select="pid"/> </td> <td> <xsl:value-of select="product_name"/> </td> <td> <select> <xsl:apply-templates select="parent::node()/parent::node()/Invoice_Customer"></xsl:apply-templates> </select> </td> <td> <a href="#myModal" data-id="{pid}" data-campid="{quoteid}" class="btn btn-primary" data-toggle="modal">Renewed</a> </td> </xsl:template> <xsl:template match="Invoice_Customer"> <option value="{cus_name}"> <xsl:value-of select="cus_name"/> </option>
这篇关于在XSLT中绑定Child元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文