Reputation: 456
I am having an xml file to filter the data using xsl-fo templating language. My 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>
I wanted to fetch the name and names values and show it on the some table-cell in xsl-fo template.
My XSL-FO template:
<?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>
I am unable to fetch the name value, getting only closefriends-->names. Need to get the name and as well as names on same table td.
Appreciate for any help..thanks
Upvotes: 0
Views: 723
Reputation: 167696
Well, instead of <xsl:value-of select="name" />
you need to select the parent's name with <xsl:value-of select="../name" />
.
Upvotes: 1