使用xml中的XSLT查找具有不同值的公共节点和取消节点 x x(v9) 0 31 乐 乐(v10) 0 0 v6 0 1. x(v9) 1. 0
我有如上所述的XML。我需要搜索变量的元素,这些元素在使用xml中的XSLT查找具有不同值的公共节点和取消节点 x x(v9) 0 31 乐 乐(v10) 0 0 v6 0 1. x(v9) 1. 0,xml,xslt,Xml,Xslt,我有如上所述的XML。我需要搜索变量的元素,这些元素在和中很常见,或者不常见。变量将仅显示一次 输出应如下所示: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <SEGMEM> <FIELD> <Entry type="Field"> <MemoryVariable>x</MemoryVariable>
和
中很常见,或者不常见。变量将仅显示一次
输出应如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<SEGMEM>
<FIELD>
<Entry type="Field">
<MemoryVariable>x</MemoryVariable>
<Variable>x(v9)</Variable>
<offset>
<lowerBound>0</lowerBound>
<upperBound>31</upperBound>
</offset>
</Entry>
<Entry type="Field">
<MemoryVariable>LE</MemoryVariable>
<Variable>LE(v10)</Variable>
<offset>
<lowerBound>0</lowerBound>
<upperBound>0</upperBound>
</offset>
</Entry>
</FIELD>
<CONGRUENCES>
<Entry type="congruence">
<Variable>v6</Variable>
<Value>
<multiplier>0</multiplier>
<offset>1</offset>
</Value>
</Entry>
<Entry type="congruence">
<Variable>x(v9)</Variable>
<Value>
<multiplier>1</multiplier>
<offset>0</offset>
</Value>
</Entry>
</CONGRUENCES>
</SEGMEM>
记忆变量
变量
下界/上界
乘数/偏移
x
x(v9)
[0,31]
[1,0]
乐
乐(v10)
[0,0]
无效的
无效的
v6
无效的
[0,1]
有专家能给出解决方案吗?我解决不了。
<table border="1">
<tr bgcolor="#9acd32">
<th>MemoryVariable</th>
<th>Variable</th>
<th>lowerbound/upperbound</th>
<th>multiplier/offset</th>
</tr>
<tr>
<td>x</td> <!-- memory variable -->
<td>x(v9)</td> <!-- x(v9) is the in file and congruence entry -->
<td>[0,31]</td> <!-- lowerbound and upperbound -->
<td>[1,0]</td> <!-- <multiplier>1</multiplier> <offset>0</offset> -->
</tr>
<tr>
<td>LE</td> <!-- memory variable again -->
<td>LE(v10)</td><!-- LE(v10) is the in file and not in congruence entry -->
<td>[0,0]</td> <!-- lowerbound and upperbound -->
<td>null</td> <!-- <multiplier>null</multiplier> <offset>null</offset> -->
</tr>
<tr>
<td>null</td> <!-- memory variable again -->
<td>v6</td> <!-- v6 is the not in file but in congruence entry -->
<td>null</td> <!-- lowerbound and upperbound -->
<td>[0,1]</td> <!-- <multiplier>0</multiplier> <offset>1</offset> -->
</tr>
</table>
记忆变量
变量
界限
相似
无效的
无效的
无效的
给你
<!-- index Entries by their Values -->
<xsl:key name="fields" match="FIELD/Entry" use="Variable" />
<xsl:key name="congruence" match="CONGRUENCES/Entry" use="Variable" />
<xsl:template match="SEGMEM">
<table border="1">
<tr bgcolor="#9acd32">
<th>MemoryVariable</th>
<th>Variable</th>
<th>Bounds</th>
<th>Congruence</th>
</tr>
<xsl:apply-templates select=".//Entry" />
</table>
</xsl:template>
<xsl:template match="Entry[parent::FIELD]">
<!-- find matching conguruence entry -->
<xsl:variable name="c" select="key('congruence', Variable)" />
<tr>
<td><xsl:value-of select="MemoryVariable" /></td>
<td><xsl:value-of select="Variable" /></td>
<td><xsl:apply-templates select="offset" mode="bracket" /></td>
<td>
<xsl:choose>
<xsl:when test="$c"><xsl:apply-templates select="$c/Value" mode="bracket" /></xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<xsl:template match="Entry[parent::CONGRUENCES]">
<!-- only output this if there is no matching field entry -->
<xsl:if test="not(key('fields', Variable))">
<tr>
<td>null</td>
<td><xsl:value-of select="Variable" /></td>
<td>null</td>
<td><xsl:apply-templates select="Value" mode="bracket" /></td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="bracket">
<xsl:value-of select="concat('[', *[1], ',', *[2], ']')" />
</xsl:template>
记忆变量
变量
界限
相似
x
x(v9)
[0,31]
[1,0]
乐
乐(v10)
[0,0]
无效的
无效的
v6
无效的
[0,1]
请参见
记忆变量
变量
界限
相似
无效的
无效的
无效的
给你
<!-- index Entries by their Values -->
<xsl:key name="fields" match="FIELD/Entry" use="Variable" />
<xsl:key name="congruence" match="CONGRUENCES/Entry" use="Variable" />
<xsl:template match="SEGMEM">
<table border="1">
<tr bgcolor="#9acd32">
<th>MemoryVariable</th>
<th>Variable</th>
<th>Bounds</th>
<th>Congruence</th>
</tr>
<xsl:apply-templates select=".//Entry" />
</table>
</xsl:template>
<xsl:template match="Entry[parent::FIELD]">
<!-- find matching conguruence entry -->
<xsl:variable name="c" select="key('congruence', Variable)" />
<tr>
<td><xsl:value-of select="MemoryVariable" /></td>
<td><xsl:value-of select="Variable" /></td>
<td><xsl:apply-templates select="offset" mode="bracket" /></td>
<td>
<xsl:choose>
<xsl:when test="$c"><xsl:apply-templates select="$c/Value" mode="bracket" /></xsl:when>
<xsl:otherwise>null</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<xsl:template match="Entry[parent::CONGRUENCES]">
<!-- only output this if there is no matching field entry -->
<xsl:if test="not(key('fields', Variable))">
<tr>
<td>null</td>
<td><xsl:value-of select="Variable" /></td>
<td>null</td>
<td><xsl:apply-templates select="Value" mode="bracket" /></td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="bracket">
<xsl:value-of select="concat('[', *[1], ',', *[2], ']')" />
</xsl:template>
记忆变量
变量
界限
相似
x
x(v9)
[0,31]
[1,0]
乐
乐(v10)
[0,0]
无效的
无效的
v6
无效的
[0,1]
请参阅感谢分享您的输入XML和预期输出!现在请添加XSLT样式表。这样,我们就可以看到您迄今为止所做的尝试。感谢您共享您的输入XML和预期输出!现在请添加XSLT样式表。那样的话,我们就可以看到你到目前为止都做了些什么。