XSLT初学者的问题 [英] XSLT beginner's question
问题描述
我有5天的XSLT经验,我确信我的问题是
几乎和他们一样基本但我无法解决,所以我希望
有人会对我表示同情 - 拜托!
我继承了一个XML文件格式,它有一个标题节点和几个子节点
:
< wi workitemid =" 99999" ....等.... />
< widata dataname =" AMOUNT" datadisplay = QUOT;金额" datavalue =" 123.45" />
< widata dataname =" ADDRESS1" datadisplay = QUOT;地址]按钮datavalue =" Line
1" >
< widata .... etc ....
我正在使用XSLT处理它们以生成HTML表格,用于
例如:
< xsl:apply-templates select =" widata [@dataname =''AGENTNAME'']"
mode =" left_left" />
模板将datadisplay的值放入一个表格单元格中,并将
的值数据值放入下一个细胞。
到目前为止,非常好。但是,我如何从两个widata
节点获取值并将它们连接起来以便我可以将它们放入一个单元格中?我知道关于concat函数但是我有问题从节点获取
的值并存储它们以便我可以使用
这个功能。
我希望我已经包含了足够的信息以便提供帮助。
谢谢。
Martin
使用变量来保存值,然后连接变量。
< td>
< xsl:variable name =" state">
< xsl:value-of select =" widata [@dataname =''ADDRESS3''] / @ datavalue" />
<! - 或其他一些节点选择 - >
< / xsl:variable>
< xsl:variable name =" zip">
< xsl:value-of select =" widata [@dataname =''ADDRESS4''] / @ datavalue" />
<! - 或其他一些节点选择 - >
< / xsl:variable>
....
< xsl:value-of select =" concat(
state,'''',
拉链)" />
....
< / td>
HTH,
-vin
Martin写道:我有5天的XSLT体验,我相信我的问题是
我继承了一个XML文件格式,其中有一个标题节点和几个子节点:
< wi workitemid =" 99999" ....等.... />
< widata dataname =" AMOUNT" datadisplay = QUOT;金额" datavalue =" 123.45" />
< widata dataname =" ADDRESS1" datadisplay = QUOT;地址]按钮datavalue =" Line
1" >
< widata ....等....
并正在使用XSLT处理它们以生成HTML表格,例如:
< xsl:apply-templates select =" widata [@dataname =''AGENTNAME'']"
mode =" left_left" />
template将datadisplay的值放入一个表格单元格中,并将datavalue的值放入下一个单元格中。
到目前为止,非常好。但是,我如何从两个widata
节点获取值并将它们连接起来以便我可以将它们放入一个单元格中?我知道concat函数,但是我在获取节点中的值并存储它们时遇到问题,以便我可以使用
该函数。
>我希望我已经提供了足够的信息以便提供帮助。
谢谢。
Martin
I have 5 days of experince with XSLT and I am sure my problem is
pretty much as basic as they come but I cannot work it out, so I hope
someone will take pity on me - please!
I have inherited an XML file format which has one header node and
several child nodes :
<wi workitemid= "99999" .... etc .... />
<widata dataname="AMOUNT" datadisplay="Amount" datavalue="123.45"/>
<widata dataname="ADDRESS1" datadisplay="Address" datavalue="Line
1" >
<widata .... etc ....
and am processing them using XSLT to produce an HTML table, by for
example :
<xsl:apply-templates select="widata[@dataname = ''AGENTNAME'']"
mode="left_left"/>
The template puts the value of datadisplay into one table cell, and
the value of datavalue into the next cell.
So far, so good. However, how would I get the values from two widata
nodes and concatenate them so that I can put them into one cell? I
know about the concat function but I am having problems getting hold
of the values from the nodes and storing them so that I can then use
that function.
I hope I have included enough info to be helpful.
Thank-you.
Martin
Use variables to hold the values and then concat the variables.
<td>
<xsl:variable name="state">
<xsl:value-of select="widata[@dataname = ''ADDRESS3'']/@datavalue" />
<!-- or some other node selection -->
</xsl:variable>
<xsl:variable name="zip">
<xsl:value-of select="widata[@dataname = ''ADDRESS4'']/@datavalue" />
<!-- or some other node selection -->
</xsl:variable>
....
<xsl:value-of select="concat(
state, '' '',
zip)" />
....
</td>
HTH,
-vin
Martin wrote:I have 5 days of experince with XSLT and I am sure my problem is
pretty much as basic as they come but I cannot work it out, so I hope
someone will take pity on me - please!
I have inherited an XML file format which has one header node and
several child nodes :
<wi workitemid= "99999" .... etc .... />
<widata dataname="AMOUNT" datadisplay="Amount" datavalue="123.45"/>
<widata dataname="ADDRESS1" datadisplay="Address" datavalue="Line
1" >
<widata .... etc ....
and am processing them using XSLT to produce an HTML table, by for
example :
<xsl:apply-templates select="widata[@dataname = ''AGENTNAME'']"
mode="left_left"/>
The template puts the value of datadisplay into one table cell, and
the value of datavalue into the next cell.
So far, so good. However, how would I get the values from two widata
nodes and concatenate them so that I can put them into one cell? I
know about the concat function but I am having problems getting hold
of the values from the nodes and storing them so that I can then use
that function.
I hope I have included enough info to be helpful.
Thank-you.
Martin
这篇关于XSLT初学者的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!