我知道这与原始问题不同,但这是我为达到以下预期结果而考虑的一个思考过程:
XML 输入:
<section hangIndent="no" indent="arabic 1 digit"
isProposedAmendment="no" label="2A">
<title>AAA</title>
<body>
BBB<subSection label="1">
<body>
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="a">
<body>
CCC
</body>
</para>
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="b">
<body>
DDD
</body>
</para>
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="c">
<body>
EEE
</body>
</para>
</body>
</subSection>
</body>
<annotation isProposedAmendment="no">
FFFFF
</annotation>
</section>
所需的输出:我根据每个节点的标签构建一个 xmlpath 名称,并将其插入每个端点。
<nm:xmlpath name ="2A" />
<section hangIndent="no" indent="arabic 1 digit"
isProposedAmendment="no" label="2A">
<title>AAA</title>
<body>
BBB
<nm:xmlpath name ="2A 1" />
<subSection label="1">
<body>
<nm:xmlpath name ="2A 1(a)" />
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="a">
<body>
CCC
</body>
</para>
<nm:xmlpath name ="2A 1(b)" />
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="b">
<body>
DDD
</body>
</para>
<nm:xmlpath name ="2A 1(c)" />
<para hangIndent="yes" indent="loweralpha 1 character"
isProposedAmendment="no" label="c">
<body>
EEE
</body>
</para>
</body>
</subSection>
</body>
<annotation isProposedAmendment="no">
FFFFF
</annotation>
</section>