かなり単純だと思う問題がありますが、頭を包むことはできません。
<p facs="001">text</p>いくつかの要素を持つ大きな XML があります。それらのテンプレートを一致させたいのですが、これにより属性を持つ p 要素が削除され、プレーンテキストになります。ファイルは「!」でトークン化する必要があります。を保持し<p facs="#">...</p>ます。また、私の不要な文の半分も削除さ<p>れます。
入力:
<root>
 <text>
    <body>
        <div>
            <p facs="001">Hello Guys! This is my example! Thanks for your time!</p>
        </div>
        <div>
            <p facs="002">Some more text! And a little more!</p>
        </div>
        <div>
            <p facs="003">Here as well! See you later!</p>
        </div>
    </body>
 </text>
</root>
私の XSLT
<xsl:stylesheet version="2.0" exclude-result-prefixes="xs"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="node() | @*">
        <xsl:copy>
            <xsl:apply-templates select="@* |node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="/root/text/body/div/p">
            <xsl:variable name="tokens" select="tokenize(text(),'!')" as="xs:string*"/>
            <xsl:variable name="words" select="remove($tokens, 1)" as="xs:string*"/>
            <xsl:for-each select="1 to xs:integer(floor(count($words) div 1))">
                <xsl:variable name="vIndex" select="(.)" as="xs:integer"/>
                <w><xsl:attribute name="n"
                    select="position()"/>
                    <xsl:value-of select="normalize-space($words[$vIndex])"/>
                </w>
            </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
私の出力:
 <root>
       <text>
          <body>
            <div>
                   <w n="1">This is my example</w>
                   <w n="2">Thanks for your time</w>
                   <w n="3"/>
            </div>
            <div>
                   <w n="1">And a little more</w>
                   <w n="2"/>
            </div>
            <div>
                   <w n="1">See you later</w>
                   <w n="2"/>
            </div>
          </body>
       </text>
    </root>
私が出力したいもの:
 <root>
       <text>
          <body>
            <div>
                <p facs="001">
                   <w n="1">Hello Guys</w>
                   <w n="2">This is my example</w>
                   <w n="3">Thanks for your time</w>
                </p>
            </div>
            <div>
                <p facs="002">
                   <w n="1">Some more Text</w>
                   <w n="2">And a little more</w>
                </p>
            </div>
            <div>
                <p facs="003">
                   <w n="1">Here as well</w>
                   <w n="2">See you later</w>
                </p>
            </div>
          </body>
       </text>
    </root>
また、必須ではありませんが、「!」をキープする方法があれば教えていただきたいです。でトークン化しました。どうすればそれらを保存できますか?
要するに: a) facs 属性を削除したくない b) 最初の文を失いたくない c) トークン化した文字を保存するにはどうすればよいですか? この例では「!」
どうもありがとう!