是否可以仅合并通过 xinclude 添加到 XML 的元素的一部分?

问题描述 投票:0回答:1

我有一个 XInclude,我正在将其合并到我的 XML 中,以便不必重复内容。这对于我的大多数用途都很有效,但在特定情况下,对象略有不同。在那里,描述性信息(下面布局中支持的“p”标签下的内容)is特定于我将 XInclude 放入的单个文件,但根据文件,只有一个“p”标签适用。我正在使用的 XInclude 是

<xi:include href="../Witness_Descriptions/Clopton_Chantry_Chapel.xml" xpointer="Clopton_Chantry_Chapel" xmlns:xi="http://www.w3.org/2001/XInclude"/>
        

从 Clopton_Chantry_Chapel.xml 文件中提取的部分如下(为了便于理解,删除了元素之间的大部分内容):

<sourceDesc xml:id="Clopton_Chantry_Chapel">
    <msDesc xml:id="Clopton">
        <msIdentifier/>
        <msContents/>
            <msItem n="Center Beam">
                <p/>
            </msItem>
            <msItem n="Crossbeams">
                <p/>
            </msItem>
            <msItem n="South Wall">
                <p/>
            </msItem>
            <msItem n="South Wall">
                <p/>
            </msItem>
            <msItem n="West Wall">
                <p/>
            </msItem>
            <msItem n="North Wall">
                <p/>
            </msItem>
            <msItem n="East Wall">
                <p/>
            </msItem>
        </msContents>
        <physDesc>
            <objectDesc>
                <supportDesc>
                    <support>
                        <material>wood</material>
                        <material>paint</material>
                        <p>The text of the "Testament" is composed on carved wooden panels intended to appear like
                            scrollwork wrapped around a typical vinework motif along the juncture between the roof and the four walls of the chapel. Each carved panel
                            was then painted to give the appearance of lined parchment.</p>
                       <p>Similarly, the text of the <emph rend="italic">Quis Dabit Meo Capiti Fontem
                            Lacrimarum</emph> is composed on badly damaged painted panels
                        intended to appear like scrollwork wrapped around a typical vinework
                        motif.</p>
                </support>
                    </support>
                </supportDesc>
                <layoutDesc>
                    <layout/>
                </layoutDesc>
            </objectDesc>
            <handDesc>
                <handNote scope="sole" script="textura quadrata">
                    <p n="hand_intro"/>
                    <p n="hand_otiose"/>
                </handNote>
            </handDesc>
            <decoDesc>
                <decoNote/>
            </decoDesc>
        </physDesc>
        <history>
            <p/>
        </history>
    </msDesc>
</sourceDesc>

我的问题是:有没有办法将特定信息折叠到我要包含的元素中,或者在 XInclude 本身中创建某种 case 语句?感觉应该有,但我知道 XML/XSLT/XPath 并不真正喜欢类似于面向对象编程的东西,而且我在网上看到的更复杂的基于 XPath 的选项似乎不适用于 Saxon ,这是我特定的解析器。那我运气不好吗?

xml xpath saxon xinclude
1个回答
0
投票

您可以尝试 sinclude 我的 Saxon 扩展函数,它实现了 XInclude。 Saxon 中的 XInclude 支持实际上是由 Xerces 提供的。它对片段标识符方案支持有限的原因之一是它在流模式下工作,我的扩展函数(无论好坏)对内存中的整个文档进行操作。

您可以使用 XPath 表达式来选择所包含文档的任意片段。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.