如果我不解释这一点,我道歉。
我需要创建一个c#应用程序,当从组合框中选择一个值时,它应该过滤掉并转换我的XSLT表。我在组合框中有3个不同的标准,这使得这很有挑战性。我现在所困扰的是设计XLST,因为标准不同。
到目前为止,这是我的XSLT表,它显示了我的所有信息。
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:variable name="features" select="programming/features/feature" />
<xsl:template match="/" >
<html>
<head>
<title>Programming</title>
</head>
<body>
<table border="1">
<tr>
<th >Programming</th>
<th >Intended Use</th>
<xsl:for-each select="$features">
<th><xsl:value-of select="."/></th>
</xsl:for-each>
<th style="text-align:left">Standards</th>
</tr>
<xsl:for-each select="programming/languages/language">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:variable name="intendedUseID" select="purpose/intendedUse/@id" />
<xsl:for-each select="/programming/purpose/intendedUse[@id=$intendedUseID]" >
<xsl:value-of select="." /> <br />
</xsl:for-each></td>
<xsl:variable name="my-features" select="features/feature" />
<xsl:for-each select="$features">
<td>
<xsl:if test="@id = $my-features/@id">Yes</xsl:if>
</td>
</xsl:for-each>
<td> <xsl:variable name="standardID" select="standards/standard/@id" />
<xsl:for-each select="/programming/standards/standard[@id=$standardID]" >
<xsl:value-of select="." /> <br />
</xsl:for-each></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="language">
<tr>
<xsl:variable name="my-features" select="features/feature" />
<xsl:for-each select="$features">
<td>
<xsl:if test="@id = $my-features/@id">Yes</xsl:if>
</td>
</xsl:for-each>
</tr>
</xsl:template>
</xsl:stylesheet>
XML
<programming>
<languages>
<language id="1">
<name>C</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="2" />
<intendedUse id="3" />
<intendedUse id="4" />
</purpose>
<features>
<feature id="1" />
<feature id="4" />
</features>
<standards>
<standard id="1" />
<standard id="2" />
</standards>
</language>
<language id="2">
<name>C++</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="2" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="3" />
<feature id="4" />
<feature id="5" />
</features>
<standards>
<standard id="2" />
</standards>
</language>
<language id="3">
<name>C#</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="5" />
<intendedUse id="6" />
<intendedUse id="7" />
<intendedUse id="3" />
<intendedUse id="8" />
<intendedUse id="9" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="3" />
<feature id="4" />
<feature id="5" />
<feature id="6" />
<feature id="7" />
</features>
<standards>
<standard id="3" />
<standard id="2" />
</standards>
</language>
<language id="4">
<name>Java</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="6" />
<intendedUse id="7" />
<intendedUse id="3" />
<intendedUse id="8" />
<intendedUse id="9" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="5" />
<feature id="6" />
</features>
<standards>
<standard id="4" />
</standards>
</language>
<language id="5">
<name>JavaScript</name>
<purpose>
<intendedUse id="7" />
<intendedUse id="8" />
<intendedUse id="7" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="3" />
<feature id="6" />
</features>
<standards>
<standard id="3" />
</standards>
</language>
<language id="6">
<name>PHP</name>
<purpose>
<intendedUse id="8" />
<intendedUse id="9" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="4" />
<feature id="6" />
</features>
<standards>
<standard id="5" />
</standards>
</language>
<language id="7">
<name>Python</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="3" />
<intendedUse id="9" />
<intendedUse id="10" />
<intendedUse id="11" />
<intendedUse id="12" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="3" />
<feature id="6" />
</features>
<standards>
<standard id="5" />
</standards>
</language>
<language id="8">
<name>Basic</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="13" />
</purpose>
<features>
<feature id="1" />
<feature id="4" />
</features>
<standards>
<standard id="1" />
<standard id="2" />
</standards>
</language>
<language id="9">
<name>ADA</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="2" />
<intendedUse id="14" />
<intendedUse id="15" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="4" />
<feature id="5" />
</features>
<standards>
<standard id="1" />
<standard id="2" />
<standard id="6" />
</standards>
</language>
<language id="10">
<name>ActionScript 3.0</name>
<purpose>
<intendedUse id="1" />
<intendedUse id="7" />
<intendedUse id="9" />
</purpose>
<features>
<feature id="1" />
<feature id="2" />
<feature id="7" />
</features>
<standards>
<standard id="3" />
</standards>
</language>
</languages>
<purpose>
<intendedUse id="1"> Application</intendedUse>
<intendedUse id="2"> System </intendedUse>
<intendedUse id="3"> General Purpose </intendedUse>
<intendedUse id="4"> Low-Level Operations </intendedUse>
<intendedUse id="5"> RAD </intendedUse>
<intendedUse id="6"> Business </intendedUse>
<intendedUse id="7"> Client-Side </intendedUse>
<intendedUse id="8"> Server-Side </intendedUse>
<intendedUse id="9"> Web </intendedUse>
<intendedUse id="10"> Scripting </intendedUse>
<intendedUse id="11"> AI </intendedUse>
<intendedUse id="12"> Scientific Computing </intendedUse>
<intendedUse id="13">Education</intendedUse>
<intendedUse id="14">Embedded</intendedUse>
<intendedUse id="15">RealTime</intendedUse>
</purpose>
<features>
<feature id="1">Imperative </feature>
<feature id="2">Object-Oriented</feature>
<feature id="3">Functional</feature>
<feature id="4">Procedural</feature>
<feature id="5">Generic</feature>
<feature id="6">Reflective</feature>
<feature id="7">Event-Driven</feature>
</features>
<standards>
<standard id="1">ANSI</standard>
<standard id="2">ISO</standard>
<standard id="3">ECMA</standard>
<standard id="4">DE FACTO</standard>
<standard id="5">NO</standard>
<standard id="6">GOST</standard>
</standards>
</programming>
下面是组合框的屏幕截图。
基本上,如果我选择标准用途,它应该显示与该标准相关的所有语言。
以下是输出的代码
<html>
<body>
<table border="1">
<tr>
<th>Programming</th>
<th>Intended Use</th>
<th>Imperative </th>
<th>Object-Oriented</th>
<th>Functional</th>
<th>Procedural</th>
<th>Generic</th>
<th>Reflective</th>
<th>Event-Driven</th>
<th style="text-align:left">Standards</th>
</tr>
<tr>
<td>C</td>
<td> Application<br> System <br> General Purpose <br> Low-Level Operations <br></td>
<td>Yes</td>
<td></td>
<td></td>
<td>Yes</td>
<td></td>
<td></td>
<td></td>
<td>ANSI<br>ISO<br></td>
</tr>
<tr>
<td>C++</td>
<td> Application<br> System <br></td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td></td>
<td>ISO<br></td>
</tr>
<tr>
<td>C#</td>
<td> Application<br> General Purpose <br> RAD <br> Business <br> Client-Side <br> Server-Side <br> Web <br></td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>ISO<br>ECMA<br></td>
</tr>
<tr>
<td>Java</td>
<td> Application<br> General Purpose <br> Business <br> Client-Side <br> Server-Side <br> Web <br></td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td></td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td>DE FACTO<br></td>
</tr>
<tr>
<td>JavaScript</td>
<td> Client-Side <br> Server-Side <br></td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td></td>
<td>Yes</td>
<td></td>
<td>ECMA<br></td>
</tr>
<tr>
<td>PHP</td>
<td> Server-Side <br> Web <br></td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td>Yes</td>
<td></td>
<td>Yes</td>
<td></td>
<td>NO<br></td>
</tr>
<tr>
<td>Python</td>
<td> Application<br> General Purpose <br> Web <br> Scripting <br> AI <br> Scientific Computing <br></td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td></td>
<td>Yes</td>
<td></td>
<td>NO<br></td>
</tr>
<tr>
<td>Basic</td>
<td> Application<br>Education<br></td>
<td>Yes</td>
<td></td>
<td></td>
<td>Yes</td>
<td></td>
<td></td>
<td></td>
<td>ANSI<br>ISO<br></td>
</tr>
<tr>
<td>ADA</td>
<td> Application<br> System <br>Embedded<br>RealTime<br></td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td></td>
<td>ANSI<br>ISO<br>GOST<br></td>
</tr>
<tr>
<td>ActionScript 3.0</td>
<td> Application<br> Client-Side <br> Web <br></td>
<td>Yes</td>
<td>Yes</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Yes</td>
<td>ECMA<br></td>
</tr>
</table>
</body>
</html>