I am having a weird issue when I generate an input Html tag from a Xsl
transformation.
When the trasform is executed on the xsl below, the <input> tag has the
closing slash removed in the first case and the closing tag removed in the
second case.
As a side note, if I change <input> to <input1>, the closing tag does not
get removed.
Thanks in advance...
The style sheet is as follows:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<HTML>
<SCRIPT type="text/javascript" language="javascript">
var parserVersion;
function window_onload()
{
buttontable.style.visibility = "visible";
buttontable.style.display = "block";
}
function ApproveDisapproveFromEmail(sUrl)
{
window.open(sUrl, "_blank", "width=600,height=200,
statusbar=no,menubar=no,toolbar=no, addressbar=no, scrollbars=yes");
}
</SCRIPT>
<BODY>
<table id="buttontable" style="font-family: sans-serif, Arial,
Verdana; font-size: 7pt; border-collapse: collapse;visibility:none;
display:none" border="0" cellpadding="4" cellspacing="0" width="201" >
<tbody>
<tr>
<td width="100px" align="center" vertical-align="center">
<tr>
<td width="100px" align="center"
vertical-align="center">
<input type = "button" value="Approve"
id="btnApprove"
onclick="ApproveDisapproveFromEmail('{//DOCINFO/APPPATH}Approve.htm?&DocumentType={//DOCINFO/DOCTYPE}&DocID={//DOCINFO/DOCID}');" />
</td>
<td width="1px"></td>
<td width="100px" align="center"
vertical-align="center">
<input type = "button" value="Disapprove"
id="btnDisapprove"
onclick="ApproveDisapproveFromEmail('{//DOCINFO/APPPATH}Disapprove.htm?&DocumentType={//DOCINFO/DOCTYPE}&DocID={//DOCINFO/DOCID}');">
</input>
</td>
</tr>
</td>
</tr>
</tbody>
</table>
<noscript>
<table style="font-family: sans-serif, Arial, Verdana;
font-size: 7pt; border-collapse: collapse" border="0" cellpadding="4"
cellspacing="0" width="201" >
<tbody>
<tr>
<td width="100px" style="background-color: #C0C0C0"
align="center" vertical-align="center">
<A>
<xsl:attribute name="href">
<xsl:value-of
select="concat(//DOCINFO/APPPATH,'Approve.htm?&DocumentType=',//DOCINFO/DOCTYPE, '&DocID=', //DOCINFO/DOCID)"/>
</xsl:attribute>Approve
</A>
</td>
<td width="1px"></td>
<td width="100px" style="background-color: #C0C0C0"
align="center" vertical-align="center">
<A>
<xsl:attribute name="href">
<xsl:value-of
select="concat(//DOCINFO/APPPATH,'Disapprove.htm?&DocumentType=',//DOCINFO/DOCTYPE, '&DocID=', //DOCINFO/DOCID)"/>
</xsl:attribute>Disapprove
</A>
</td>
</tr>
</tbody>
</table>
</noscript>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
And the code that processes it is as follows:
private string GetApprovalEmailBody(AcDocument Doc)
{
string strBody = Doc.GetApprovalEmailBody();
//FORM THE XML
XmlDocument MainDocument = new XmlDocument();
string strinfo = "<TOP><DOCINFO><DOCTYPE>" + Doc.Type +
"</DOCTYPE><DOCID>" + Doc.DocID + "</DOCID><APPPATH>" + Doc.ApplicationPath +
"</APPPATH></DOCINFO></TOP>";
MainDocument.LoadXml(strinfo);
//Start the transformation process here
System.IO.StringReader reader = new
System.IO.StringReader(MainDocument.InnerXml);
XPathDocument xmlDoc = new XPathDocument(reader);
XmlDocument xslPage = new XmlDocument();
xslPage.Load(Doc.ApplicationPath +
"Tools/PrepareEmailButtonsHTML.xsl");
XslCompiledTransform xslDoc = new XslCompiledTransform();
xslDoc.Load(xslPage);
System.IO.StringWriter writer = new System.IO.StringWriter();
xslDoc.Transform(xmlDoc, null, writer);
string strButtonHTML = writer.ToString();
if (strButtonHTML == "")
throw (new Exception("Workflow.GetApprovalEmailBody: Error in
preparing the html for buttons. Please contact the administrator"));
XmlDocument TopDocument = new XmlDocument();
TopDocument.LoadXml(strButtonHTML);
Martin Honnen - 21 Jul 2006 13:16 GMT
> When the trasform is executed on the xsl below, the <input> tag has the
> closing slash removed in the first case and the closing tag removed in the
> second case.
Well to generate proper HTML the XSLT processor has to output an empty
element like the input element the HTML way and that is simply
<input>
and not the XML way (which would be
<input/>
or
<input></input>
).
If you don't want the output method html then use
<xsl:output method="xml" />
in the stylesheets but if you want to send HTML to browsers then the
html output method is the right thing.
There are three output methods in XSLT 1.0, html, xml, and text. If you
don't specify one but have a root element with tag name HTML (case
insensitive) and no namespace then html is the default.
You have
<xsl:template match="/">
<HTML>
so the processor uses output method html.
> As a side note, if I change <input> to <input1>, the closing tag does not
> get removed.
[quoted text clipped - 112 lines]
> XmlDocument TopDocument = new XmlDocument();
> TopDocument.LoadXml(strButtonHTML);

Signature
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/