別の XML ドキュメントからデータをフィルタリングするのに役立つドキュメントを作成しようとしています。例えば
<document>
    <filter>
        <what>
            <include>
                <marital_staus/>
                <ms>single</ms> <!--nog = no of groups-->
                <include>
                    <memberofgroups/>
                    <gn>Football club</gn> <!--user is a member of this club-->
                </include>
            </include>
        </what>
    </filter>
    <users>
            <user>
                <name>
                    <first>abc</first>
                    <last>xyz</last>
                </name>
                <dob>12/02/1987</dob>
                <marital_status>married</marital_status>
                <groups>
                    <member_of_group>Chess Club</member_of_group>
                    <member_of_group>Football club</member_of_group>
                </groups>
            </user>
            <user>
                <name>
                    <first>aaa</first>
                    <last>bbb</last>
                </name>
                <dob>14/03/1987</dob>
                <marital_status>single</marital_status>
                <groups>
                    <member_of_group>Chess Club</member_of_group>
                    <member_of_group>Football club</member_of_group>
                </groups>
            </user>
             <user>
                <name>
                    <first>fff</first>
                    <last>nnn</last>
                </name>
                <dob>12/6/1983</dob>
                <marital_status>single</marital_status>
                <groups>
                    <member_of_group>Chess Club</member_of_group>
                    <member_of_group>Cultural Association</member_of_group>
                </groups>
            </user>
     </users>
</document>
このコードで実行したいことは、最初にフットボール クラブのメンバーであるユーザーを選択し、その中から独身のユーザーを選択することです。しかし、このスタイルシートの書き方がわかりません。私はこれを書きました:
<xsl:template name="temp">
        <xsl:param name="a1"/>
        <xsl:param name="pro"/>
        <xsl:choose>
            <xsl:when test="$pro = 'marital_status'">
                <xsl:for-each select="/document/users/user">
                    <xsl:if test="marital_status=$a1">
                        <xsl:value-of select="."/>
                    </xsl:if>                
                </xsl:for-each>
            </xsl:when>
            <xsl:when test="$pro = 'memberofgroups'">
            <xsl:for-each select="/document/users/user">
                <xsl:for-each select="./groups/member_of_group">
                    <xsl:if test=".=$a1">
                        <xsl:value-of select="."/>
                    </xsl:if>
                </xsl:for-each>
            </xsl:for-each>
        </xsl:when>
        </xsl:choose>
    </xsl:template>
<xsl:template match="include">
        <xsl:call-template name="temp">
            <xsl:with-param name="a1">
                <xsl:apply-templates select="*[2]"/>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>
テンプレートを呼び出すときに、正しい値を渡すと思います。
問題は、独身のすべてのユーザーと、その特定のグループのメンバーであるすべてのユーザーを取得することです。ただし、サッカークラブのメンバーでもあるシングルユーザーが必要です。他の要素に基づいてフィルタリングも行いたいので、スタイルシートをハードコーディングしたくありません。
フィルター処理された要素を、次の XPath 式の入力として使用できるものに保存する方法がわかりません。それとも、ドキュメントをフィルタリングするための制約を書いているときに間違いを犯していますか? または、フィルタリング用のドキュメントを作成するためのより適切な方法が他にあるでしょうか? あなたの助けに感謝します。