我将 for-each-group 应用于一组 XML 进行排序。现在我需要添加一个过滤器以不处理组参数存在于另一个变量中的记录。我不确定正确的 XPath 语句是什么。示例 XML 输入
输入 1 - $XMLRecords
<root>
<row>
<field1>Record 1-1</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter1</groupby>
</row>
<row>
<field1>Record 1-2</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter1</groupby>
</row>
<row>
<field1>Record 2-1</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter2</groupby>
</row>
<row>
<field1>Record 2-2</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter2</groupby>
</row>
<row>
<field1>Record 3-1</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter3</groupby>
</row>
<row>
<field1>Record 3-2</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter3</groupby>
</row>
<row>
<field1>Record 4-1</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter3</groupby>
</row>
<row>
<field1>Record 4-2</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter4</groupby>
</row>
</root>
输入 2 - $RecordsToSkip
<root>
<row>GroupByParamter2</row>
<row>GroupByParamter4</row>
</root>
输入 2 模式
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="row">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="line" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
输出 - 需要处理的记录
<root>
<row>
<field1>Record 1-1</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter1</groupby>
</row>
<row>
<field1>Record 1-2</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter1</groupby>
</row>
<row>
<field1>Record 3-1</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter3</groupby>
</row>
<row>
<field1>Record 3-2</field1>
<field2>TEXT</field2>
<groupby>GroupByParameter3</groupby>
</row>
</root>
这是当前的 XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="RecordsToSkip" select="bpws:getVariableData('recordsToSkip')"/>
<xsl:variable name="XMLRecords" select="bpws:getVariableData('xmlRecords')"/>
<xsl:template match="/">
<xsl:element name="root">
<xsl:for-each-group select="$XMLRecords/*:root/*:row" group-by="groupby">
<xsl:call-template name="sortData">
<xsl:with-param name="groupbyparameter" select="groupby"/>
</xsl:call-template>
</xsl:for-each-group>
</xsl:element>
</xsl:template>
<xsl:template name="sortData">
<xsl:param name="groupbyparameter"/>
<--! group specific logic -->
</xsl:template>
</xsl:stylesheet>
我想我正在尝试在调用模板语句周围放置一个“如果 groupby 不是 RecordsToFilter 变量的子项”