首页 > 解决方案 > 全文链接即将到来

问题描述

嗨,我有以下输入 xml 文件:

<Description>See <XRef href="push">Time</XRef>, <XRef href="back">Late</XRef>,  <XRef href="some">Come</XRef></Description>

XSL 我试过上面的代码:

<xsl:template match="Description">
        <def>
            <para>
                <xsl:value-of select="normalize-space(node()[1])"/>
                <xsl:if test="XRef">
                    <xsl:choose>
                        <xsl:when test="TEST">
                            <xref>
                                <xsl:attribute name="endterm">

                                </xsl:attribute>
                                <xsl:attribute name="linkend">

                                </xsl:attribute>
                            </xref>
                        </xsl:when>
                        <xsl:otherwise>
                            <link>
                                <xsl:choose>
                                    <xsl:when test="@destination='yes'">
                                        <xsl:attribute name="xlink:href">
                                            <xsl:text>test.pdf</xsl:text>
                                        </xsl:attribute> 
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:attribute name="mark">

                                        </xsl:attribute> 
                                    </xsl:otherwise>
                                </xsl:choose>
                                <xsl:value-of select="."/>       
                            </link>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:if>
                </para>
        </def>
    </xsl:template>

像这样获取输出:

<def>
   <para>See<link mark="">See Time, Late, Come</link></para>
</def>

预期输出如下:

<def>
    <para>See <link mark="">Time</link>, <link mark="">Late</link>, <link mark="">Come</link></para>
</def>

我正在获取整个外部参照的链接,但我需要单独的链接。请为此建议一个代码。

标签: xmlxsltxslt-2.0

解决方案


更改以下代码:-

<xsl:if test="XRef">
       **to**
<xsl:for-each select="XRef">

</xsl:if>
   **to**
</xsl:for-each>

推荐阅读