Trying to use an Xslt for an xml in asp.net

Posted by Josemalive on Stack Overflow See other posts from Stack Overflow or by Josemalive
Published on 2010-05-19T09:11:13Z Indexed on 2010/05/19 9:20 UTC
Read the original article Hit count: 373

Filed under:
|
|
|

Hello,

i have the following xslt sheet:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:variable name="nhits" select="Answer[@nhits]"></xsl:variable>
  <xsl:output method="html" indent="yes"/>
  <xsl:template match="/">
    <div>
      <xsl:call-template name="resultsnumbertemplate"/>
    </div>
  </xsl:template>  
  <xsl:template name="resultsnumbertemplate">
    <xsl:value-of select="$nhits"/> matches found
  </xsl:template>  
</xsl:stylesheet>

And this is the xml that im trying to mix with the previous xslt:

<Answer xmlns="exa:com.exalead.search.v10" context="n%3Dsl-ocu%26q%3Dlavadoras" last="9" estimated="false" nmatches="219" nslices="0" nhits="219" start="0">
  <time>
    <Time interrupted="false" overall="32348" parse="0" spell="0" exec="1241" synthesis="15302" cats="14061" kwds="14061">
      <sliceTimes>15272 </sliceTimes>
    </Time>
  </time>    
</Answer>

Im using a xslcompiledtransform and that's working fine:

XslCompiledTransform transformer = new XslCompiledTransform();

transformer.Load(HttpContext.Current.Server.MapPath("xslt\\" + requestvariables["xslsheet"].ToString()));

transformer.Transform(xmlreader, null, writer);

My problems comes when im trying to put into a variable the "nhits" attribute value placed on the Answer element, but i'm not rendering anything using my xslt sheet.

Do you know what could be the cause?

Could be the xmlns attribute in my xml file?

Thanks in advance.

Best Regards.

Jose

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about xslt