I have a simple XML document that contains image information. I need to transform it to HTML -- simple, right? However, when I use the XSL below, it blows up with the error "Cannot write an attribute node when no element start tag is open." I can't see where the open tag is -- any ideas?
XML:
<root> <HeaderText> <HeaderText>Dan Testing</HeaderText> </HeaderText> <Image> <img width="100" height="100" alt="FPO lady" src="/uploadedImages/temp_photo_small.jpg"/> </Image> <BodyText> <p>This is a test of the body text<br /></p> </BodyText> <ShowLinkArrow>false</ShowLinkArrow> </root>
XSL:
<xsl:stylesheet version="1.0" extension-element-prefixes="msxsl" exclude-result-prefixes="msxsl js dl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:js="urn:custom-javascript" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:dl="urn:datalist"> <xsl:output method="xml" version="1.0" omit-xml-declaration="yes" indent="yes" encoding="utf-8"/> <xsl:template match="/" xml:space="preserve"> <img> <xsl:attribute name="width"> 100 </xsl:attribute> <xsl:attribute name="height"> 100 </xsl:attribute> <xsl:attribute name="class"> CalloutRightPhoto </xsl:attribute> <xsl:attribute name="src"> <xsl:copy-of select="/root/Image/node()"/> </xsl:attribute> </img> </xsl:template> </xsl:stylesheet>