请原谅我之前的类似帖子。希望我可以从很好的反馈中学习,但仍然在 XPath 上有点挣扎。对于类似的帖子,我再次感到抱歉!
当前 XML
<?xml version="1.0" encoding="utf-8" ?>
<data>
<table_1 dropdown1="Item1"></table_1>
<listitems key1="Item1" name="" key2="Id2"/>
<listitems key1="Item1" name="Item A" key2="Id2"/>
<listitems key1="Item1" name="Item B" key2="Id2"/>
<listitems key1="Item1" name="" key2="Id4"/>
<listitems key1="Item1" name="Item A" key2="Id4"/>
<listitems key1="Item1" name="Item B" key2="Id4"/>
<listitems key1="Item2" name="" key2="Id6"/>
<listitems key1="Item2" name="Item C" key2="Id6"/>
<listitems key1="Item2" name="Item D" key2="Id6"/>
</data>
当前 XSL
<xsl:template match="/">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<xsl:for-each select="/data/listitems[@key1=/data/table_1/@dropdown1]">
<xsl:value-of select="@name"/>
<br/>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="listitems">
<xsl:value-of select="concat(@name, ' ')" />
</xsl:template>
当前结果: