英文:
RTF dynamic data columns for group of columns
问题
成功地使用一个列作为值,按照这里的示例,我设法将我的行显示为列。
但是,我无法找到一种方法来显示每个分割的列的两个值而不是一个值,尽管我已经尽力了。最接近的结果是模板会连续显示所有行中的第一列,然后连续显示第二列的值。
这是我的RTF的外观:
这是我的XML的外观:
<DATA_DS>
<ASSETS_DS>
<COMP_DESC>ABC</COMP_DESC>
<ASTS>111</ASTS>
<ASTS_ERC>1.2</ASTS_REC>
<LONS>222</LONS>
<LONS_ERC>2.2</LONS_REC>
</ASSETS_DS>
<ASSETS_DS>
<COMP_DESC>EFG</COMP_DESC>
<ASTS>333</ASTS>
<ASTS_ERC>3.1</ASTS_REC>
<LONS>444</LONS>
<LONS_ERC>4.1</LONS_REC>
</ASSETS_DS>
</DATA_DS>
这是我的期望输出:
这是当前的输出:
但由于我尝试合并公司名称的Description列以显示值和百分比,所以显示紧凑。如第一图所示,有办法将值和百分比列并排显示吗?
英文:
I managed to display my rows into columns successfully using one column as a value following the example here
But I am not able to find a way to show two values instead of one for each column I split, I have tried my best, but the closest thing I can get is that the template will show the first column for all the rows I am splitting consecutively, then it will show the second column value for all the columns consecutively.
This is how my RTF looks like:
this is how my XML looks like:
<DATA_DS>
<ASSETS_DS>
<COMP_DESC>ABC</COMP_DESC>
<ASTS>111</ASTS>
<ASTS_ERC>1.2</ASTS_REC>
<LONS>222</LONS>
<LONS_ERC>2.2</LONS_REC>
</ASSETS_DS>
<ASSETS_DS>
<COMP_DESC>EFG</COMP_DESC>
<ASTS>333</ASTS>
<ASTS_ERC>3.1</ASTS_REC>
<LONS>444</LONS>
<LONS_ERC>4.1</LONS_REC>
</ASSETS_DS>
</DATA_DS>
This is my desired output:
This is the current output:
But a cramped display due to my tries to merge the Description column for company name to show Value and Percentage together as shown in the first figure
So, is there a way to show Value and Percentage columns next to each other?
答案1
得分: 1
请尝试以下内容:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="DATA_DS">
<html>
<body>
<table border="1">
<tr>
<xsl:for-each select="ASSETS_DS">
<td> </td><td><xsl:value-of select="COMP_DESC"/></td>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="ASSETS_DS">
<xsl:if test="position()=1"><td> </td></xsl:if><td><xsl:value-of select="'value'"/></td><td><xsl:value-of select="'Percentage'"/></td>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="ASSETS_DS">
<xsl:if test="position()=1"><td>Assets</td></xsl:if><td><xsl:value-of select="ASTS"/></td><td><xsl:value-of select="ASTS_REC"/></td>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="ASSETS_DS">
<xsl:if test="position()=1"><td>Loans</td></xsl:if><td><xsl:value-of select="LONS"/></td><td><xsl:value-of select="LONS_REC"/></td>
</xsl:for-each>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
英文:
Try this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="DATA_DS">
<html>
<body>
<table border="1">
<tr>
<xsl:for-each select="ASSETS_DS">
<td> </td><td><xsl:value-of select="COMP_DESC"/></td>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="ASSETS_DS">
<xsl:if test="position()=1"><td> </td></xsl:if><td><xsl:value-of select="'value'"/></td><td><xsl:value-of select="'Percentage'"/></td>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="ASSETS_DS">
<xsl:if test="position()=1"><td>Assets</td></xsl:if><td><xsl:value-of select="ASTS"/></td><td><xsl:value-of select="ASTS_REC"/></td>
</xsl:for-each>
</tr>
<tr>
<xsl:for-each select="ASSETS_DS">
<xsl:if test="position()=1"><td>Loans</td></xsl:if><td><xsl:value-of select="LONS"/></td><td><xsl:value-of select="LONS_REC"/></td>
</xsl:for-each>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论