c# - how to pass dynamically created xml in XsltArgumentList msxsl -


i in fix here have pass dynamically created xml in c# code passed xslt param , values it.

following sample xslt

<xsl:stylesheet   xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"   version="1.0">   <xsl:param name="keys"></xsl:param>      <xsl:template match="/">     <mykey>mynode</mykey>     <xsl:value-of select="msxsl:node-set($keys)/keys/item/header"/>    </xsl:template>  </xsl:stylesheet> 

then code in c# call transform method

xslcompiledtransform proc = new xslcompiledtransform(); proc.load("sheet.xslt");  xsltargumentlist xsltargs = new xsltargumentlist();  xmldocument doc1 = new xmldocument(); // populate needed e.g. doc1.loadxml("<keys><item><header>fooheader</header></item></keys>");  xsltargs.addparam("keys", "", doc1.innerxml.tostring());  // pass xsltargs second argument transform method  proc.transform(someinput, xsltargs, someoutput); 

here not able value mynode in results thanks

you have 2 problems here. firstly how pass parameters

xsltargs.addparam("doc1", "", doc1); 

but in xslt have named "keys"

<xsl:param name="keys"></xsl:param>   

therefore need change c# code

xsltargs.addparam("keys", "", doc1); 

there problem xslt.

<xsl:value-of select="msxsl:node-set($keys)/keys/item/header"/>  

xml case-sensitive. xml contains "item", xslt looking "item". should these

<xsl:value-of select="msxsl:node-set($keys)/keys/item/header"/>  

infact, don't think need node-set here. try too

<xsl:value-of select="$keys/keys/item/header"/>  

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -