我有一个xml文件来使用xsl-fo模板语言过滤数据。我的XML:
<root>
<name>shyam</name>
<friend>
<name>Abc</name>
<phNo>90909090909</phNo>
<age>32</age>
<closefriends>
<names>test123</names>
</closefriends>
</friend>
<friend>
<name>Xyz</name>
<phNo>32323232323</phNo>
<age>44</age>
<closefriends>
<names>test345</names>
</closefriends>
</friend>
</root>
我想获取名称和名称值,并将其显示在xsl-fo模板中的某些表格单元格上。
我的XSL-FO模板:
<?xml version="1.0" encoding="iso-8859-1"?>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello,
<xsl:value-of select="name" />!</fo:block>
<fo:block>
<fo:table>
<fo:table-body>
<fo:table-row>
<fo:table-cell border="solid 1px black" text-align="center" font-weight="bold">
<fo:block>
No.
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center" font-weight="bold">
<fo:block>
Name
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center" font-weight="bold">
<fo:block>
Phone Number
</fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="./friend">
<xsl:for-each select="./closefriends">
<fo:table-row>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="position()" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="name" />
<xsl:value-of select="names" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid 1px black" text-align="center">
<fo:block>
<xsl:value-of select="phNo" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
我无法获取名称值,只获得了亲密朋友 - &gt;名称。需要在同一个表td上获取名称和名称。
感谢任何帮助..谢谢
答案 0 :(得分:1)
嗯,您需要使用<xsl:value-of select="name" />
选择父级名称,而不是<xsl:value-of select="../name" />
。