![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: node-set($variable) just won't allow any results - what do I need to change? node-set($variable) just won't allow any results - what do I need to change?To: NULL Date: 7/6/2007 12:24:00 AM I've been struggling with my first non-trivial XSLT for weeks now, and I've been unable to figure out what should be a simple problem to solve. I first had to learn the hard lesson of Result Tree Fragments and dynamic XPath evaluation with XSLT 1.0, and then to infer the expected behaviour of the msxsl:node-set() extension function. However, for whatever reason when I use a variable in my select statement it produces no results. When I hard-code one variant of the XPath into the same call, it gives me exactly the results I'm after. [[1]] Here's the entire XSL including the hard-coded node-set() call that works: <?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"> <xsl:output method="html" version="4.0"/> <xsl:template match="ThreatModel"> <html> <head> <LINK href="styles.css" rel="stylesheet" type="text/css"/> </head> <body> <div class="mainSection">Details: Enumeration of Threats</div> <br/> <xsl:call-template name="CreateThreatsTable"> <xsl:with-param name="RiskResponse">Reduce</xsl:with-param> </xsl:call-template> <xsl:call-template name="CreateThreatsTable"> <xsl:with-param name="RiskResponse">Transfer</xsl:with- param> </xsl:call-template> </body> </html> </xsl:template> <xsl:template name="CreateThreatsTable" match="/ThreatModel/ Threats"> <xsl:param name="RiskResponse"/> <TABLE cellPadding="0" cellSpacing="1"> <TR> <TD class="itemHeader" colspan="4"> Threat Analysis: Threats we have decided to <xsl:value-of select="$RiskResponse"/> </TD> </TR> <TR> <TD class="subHeader">Threat</TD> <TD class="subHeader">Risk_Severity</TD> <TD class="subHeader">Threat_Category</TD> <TD class="subHeader">Description</TD> </TR> <!-- This template filters the displayed records to those that match the selected Risk Response --> <xsl:call-template name="AddRowsToTable"> <xsl:with-param name="ThreatCategory">ConfidentialityThreat</ xsl:with-param> <xsl:with-param name="RiskResponse">Reduce</xsl:with-param> </xsl:call-template> </TABLE> <br/> </xsl:template> <xsl:template name="AddRowsToTable" match="/ThreatModel/Threats"> <xsl:param name="ThreatCategory"/> <xsl:param name="RiskResponse"/> <xsl:variable name="ThreatXPath"> <xsl:value-of select="concat('/ThreatModel/Threats/', $ThreatCategory, 's/Threats/', $ThreatCategory)"/> </xsl:variable> <xsl:for-each select="/ThreatModel/Threats/ConfidentialityThreats/ Threats/ConfidentialityThreat[Risk = $RiskResponse]"> <TR> <TD valign="top"> <xsl:value-of select="Name"/> </TD> <TD valign="top"> <xsl:value-of select="RiskRating"/> </TD> <TD valign="top"> <xsl:value-of select="../../Name"/> </TD> <TD valign="top"> <xsl:value-of select="Description"/> </TD> </TR> </xsl:for-each> </xsl:template> </xsl:stylesheet> [[2]] Here's the call I'd *LIKE* to make in that XSL: <xsl:for-each select="msxsl:node-set($ThreatXPath)[Risk = $RiskResponse]" > (Though I'd even settle for just <xsl:for-each select="msxsl:node- set($ThreatXPath)" > ) [[3]] Here's an example XML fragment (representing a single Threat): <?xml version="1.0" encoding="utf-8"?> <ThreatModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Threats> <Name>Threats</Name> <ConfidentialityThreats> <Name>Confidentiality Threats</Name> <Threats> <ConfidentialityThreat> <Name>Attacker reboots device from external media and reads sensitive data</Name> <Description>This describes it nicely.</Description> <Risk>Reduce</Risk> <RiskRating>9</RiskRating> </ConfidentialityThreat> [[4]] Here's the output that [[1]] produces from [[3]] (without the table formatting): Details: Enumeration of Threats Threat Analysis: Threats we have decided to Reduce Threat Risk_Severity Threat_Category Description Attacker reboots device from external media and reads sensitive data 9 Confidentiality Threats This describes it nicely. Threat Analysis: Threats we have decided to Transfer Threat Risk Severity Threat Category Description [[5]] And here's the output that [[2]] produces from [[3]]: Details: Enumeration of Threats Threat Analysis: Threats we have decided to Reduce Threat Risk_Severity Threat_Category Description Threat Analysis: Threats we have decided to Transfer Threat Risk Severity Threat Category Description ===== I could swear I've done everything the same way that dozens of newsgroup postings have indicated over the years - but still I'm vexed by the same problem as everyone else seems to have. I've debugged each statement (using VStudio 2005 and Stylus Studio 2007 XML Professional), and I've tried all kinds of combinations of tricks I've found on various newsgroups & forums that don't seem to help fix this issue. The operating environment is Windows XPSP2 with an IE-based application (so I'm assuming MSXML and like 6.0). Can anyone help me figure out what I'm missing here? This is driving me nuts! I suspect it's something obvious, but after weeks of staring at this code I can't see it. [Hell, I can hardly remember what it was I was trying to achieve with this...] Thanks, Mike | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
