Reputation: 71
This is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="staff.xsl"?>
<st>
<employee>
<name>
<firstname>Clay</firstname>
<lastname>Hansen</lastname>
</name>
<jobtitle>Professor</jobtitle>
<department>Department: Communication and Marketing</department>
<office>Office: CH-H 111</office>
<phone>Phone: (847)257-1234</phone>
<email>Email: [email protected]</email>
<profile>
<html xmlns="http://www.w3.org/1999/xhtml">
<img src="C:\Users\username\Desktop\im.jpg" /> <!-- added closing tag by edit -->
</html>
</profile>
</employee>
</st>
here is my xml and extrenal xsl code. When I add an image, it does not display my data in tabular form. It displays it like words in a sentence. How can I solve it?
Upvotes: 2
Views: 59
Reputation: 1103
This is because xsl:value-of
returns the concatenated text nodes of a element's subtree with the markup removed (in your case there is none). You could copy the img
node like this:
<xsl:for-each select="employee">
<td>
<xsl:copy-of select="profile//xhtml:img"></xsl:copy-of>
</td>
</xsl:for-each>
Note, that you have to declare the xhtml namespace in your stylesheet to process the img
nodes:
xmlns:xhtml="http://www.w3.org/1999/xhtml"
Upvotes: 3