2
輸入XML是像如下所示:XSLT - 使用正則表達式複製部分屬性值
<figure>
<subfigure>
<graphic id="c001_f001" position="center" fileref="images/9781626232396_c001_f001.jpg"/>
<legend><para><target/><emph type="bold"><emph type="italic">Fig. 1.1</emph> </emph><emph type="bold">Embryonic development</emph> (after Sadler)</para>
<para>Age in postovulatory days.</para>
</subfigure>
</figure>
輸出應該
<figure>
<subfigure id="c001">
<graphic id="c001_f001" position="center" fileref="images/9781626232396_c001_f001.jpg"/>
<legend><para><target/><emph type="bold"><emph type="italic">Fig. 1.1</emph></emph><emph type="bold">Embryonic development</emph> (after Sadler)</para>
<para>Age in postovulatory days.</para>
</subfigure>
</figure>
XSLT:
<xsl:template match="subfigure">
<xsl:copy>
<xsl:attribute name="id">
<xsl:value-of select="graphic/@id"></xsl:value-of>
</xsl:attribute>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
每次屬性「id」值是不同的。我們需要將「id」值的第一部分複製並粘貼到子圖ID中。你能幫我們解決這個問題嗎?
謝謝你你的迴應Tim – Sumathi