Autoclose xml tag during xslt transformation -


i have :

<input type="checkbox" name="idsproduct" value="{@id}"         id="form_checkbox_product_{@id}">     <xsl:if test="$x=$y">         <xsl:attribute name="checked" >checked</xsl:attribute>     </xsl:if> </input> 

and :

  <input type="checkbox" name="idsproduct" value="26294"          id="form_checkbox_product_26294" checked="checked"></input> 

i want input tag :

<input type="checkbox" name="idsproduct" value="26294"         id="form_checkbox_product_26294" checked="checked" /> 

my xsl output :

 <xsl:output        omit-xml-declaration="yes"        method="xml"       encoding="utf-8"       indent="no" /> 

how can autoclose tag?

this similar question (although problem direct inverse):

using xsl:if doesn't include closing tag

there's discussion of 'trick' here causes longer form of closed element used, appear inadvertently using here, in different form. suspect problem because you're asking xslt output directly text. outputting xml document first, , serializing should solve problem.

here's extension method used transforming xmldocument rather string, can read .outerxml property of if want string equivalent; because xslt isn't doing outputting text, should treat closed tags correctly.

    public static xmldocument transform(this xmldocument input, xslcompiledtransform xslt)     {         xmldocument outdoc = new xmldocument(input.createnavigator().nametable);         using (xmlwriter xr = outdoc.createnavigator().appendchild())         {             xslt.transform(input, xr);         }          return outdoc;     } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -