我有以下XML文件,该文件在以下XML节点上定义了图形ID
mainProcedure / proceduralStep /对/ @ internalRefId
created=False
在同一XML文件中,Figure数据已在以下XML节点上定义。
<mainProcedure>
<proceduralStep id="stp-0001">
<title> <inlineSignificantData significantParaDataType="psd52">SUBTASK 72-31-00-030-051</inlineSignificantData> Prepare the Turnover Stand for Installation of the LP Compressor (Fan) Module</title>
<proceduralStep id="stp-0002">
<para>Refer to <internalRef internalRefId="fig-0002" internalRefTargetType="figure"/>.</para>
</proceduralStep>
<proceduralStep id="stp-0013">
<title> <inlineSignificantData significantParaDataType="psd52">SUBTASK 72-31-00-030-052</inlineSignificantData> Install the LP Compressor (Fan) Module to the Turnover Stand</title>
<proceduralStep id="stp-0014">
<para>Refer to <internalRef internalRefId="fig-0003" internalRefTargetType="figure"/>, <internalRef internalRefId="fig-0004" internalRefTargetType="figure"/>, <internalRef internalRefId="fig-0005" internalRefTargetType="figure"/>, <internalRef internalRefId="fig-0006" internalRefTargetType="figure"/> and <internalRef internalRefId="fig-0007" internalRefTargetType="figure"/>.</para>
</proceduralStep>
<figure id="fig-0001">
<title>Sectional View of the LP Compressor (Fan) Module</title>
<graphic infoEntityIdent="ICN-IHIX1-A0-72310000-R-Z5H62-10946-A-001-01"/>
</figure>
<figure id="fig-0002">
<title>Prepare the Turnover Stand for Installation of the LP Compressor (Fan) Module</title>
<graphic infoEntityIdent="ICN-IHIX1-A0-72310000-R-Z5H62-10947-A-001-01"/>
</figure>
</mainProcedure>
所以现在我将匹配mainProcedure / procedural并从node和infoEntityIdent中找到相应的图形ID,显示此infoEntityIdent如下所示
所以最终结果应该是
<figure id="fig-0001">
<title>Sectional View of the LP Compressor (Fan) Module</title>
<graphic infoEntityIdent="ICN-IHIX1-A0-72310000-R-Z5H62-10946-A-001-01"/>
</figure>
拜托,你能帮我设计一下这个xsl吗?
答案 0 :(得分:1)
定义一个键<xsl:key name="figure" match="figure" use="@id"/>
,然后,在xsl:template match="para/internalRef"
的上下文中,您可以使用例如key('figure', internalRefId)
找到引用的figure
,这样您就可以使用key('figure', internalRefId)/graphic/@infoEntityIdent
来选择您要查找的属性值,例如<div id="{key('figure', internalRefId)/graphic/@infoEntityIdent}">...</div>
import numpy as np
n_sim = 10
n_flip = 100
sims = np.empty(n_sim)
for j in xrange(n_sim):
flips = np.random.randint(0, 2, n_flip)
sims[j] = np.sum(flips)
。