Am 18.08.2022 um 16:27 schrieb rick@xxxxxxxxxxxxxx:
>
>
> I have an input file that I want to split into files at each section.
> The first section should include everything before it. Below are my
> input, desired output, and stylesheet. I am pretty sure this is the
> simplest approach, but any suggestions would be appreciated.
>
> Rick
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <chapter id="Assault_gd1g1l1027760">
>
> B B B <title>Transferred Intent</title>
>
> B B B <toc/>
>
> B B B <para/>
>
> B B B <section id="GI_gd1g1o1030579">
>
> B B B B B B B <title>General Comments</title>
>
> B B B B B B B <para>General comments here</para>
>
> B B B </section>
>
> B B B <section id="GI_gd1g1p1030593">
>
> <title>InstructionbTransferred IntentbDifferent Offense</title>
>
> B B B B B B B <para>Instructions here</para>
>
> B B B </section>
>
> B B B <section id="GI_gd1g1q1030657">
>
> <title>InstructionbTransferred IntentbDifferent Person or
> Propertyo?=</title>
>
> B B B B B B B <para>More instructions here</para>
>
> B B B </section>
>
> </chapter>
>
Is the content of chapter always some unknown elements plus a sequence
of section elements?
In that case you could of course also simply map section to file
elements with e.g.
B <xsl:template match="section">
B <file>
B B B <xsl:copy-of select="."/>
B </file>
</xsl:template>
<xsl:template match="section[1]">
B <file>
B B B <xsl:copy-of select="preceding-sibling::*, ."/>
B </file>
</xsl:template>
<xsl:template match="chapter/*[not(self::section)]"/>
|