2010-01-26 78 views
1

我想通过参数(通过C#)传递给下面的XSLT来构建一个查询与多个过滤器,但它不工作。我做错了什么,做这件事的正确方法是什么?xsl:参数和多个过滤器

(这个过滤器可以通过硬编码值和参数值打通到XSLT)

谢谢!

<?xml version="1.0" encoding="utf-8"?> 

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> 
    <xsl:output method="html" /> 
    <xsl:param name="SensorBandName" /> 
    <xsl:param name="SensorBandFrequencyName" /> 
    <xsl:template match="Sensor"> 
    <html> 
     <head> 
     <title></title> 
     </head> 
     <body> 
     <p> 
      <xsl:value-of select="Bands/SensorBand[Name='$SensorBandName']/Frequencies/SensorBandFrequency[Name='$SensorBandFrequencyName']" /> 
     </p> 
     </body> 
    </html> 
    </xsl:template> 
</xsl:stylesheet> 

回答

2

不要引用变量/参数名称!

<xsl:value-of select="Bands/SensorBand[Name=$SensorBandName]/Frequencies/SensorBandFrequency[Name=$SensorBandFrequencyName]" /> 
+0

谢谢!这工作! – Gerard 2010-01-26 16:20:05

+0

不客气。然而,你可以接受它作为答案,因为我比鲁本斯提前一分钟发布了它,否则...;) – Lucero 2010-01-26 17:01:56

+1

我同意,所以我给了你+1 – 2010-01-26 17:32:17