XSLT我需要根据param值过滤元素

XSLT我需要根据param值过滤元素,xslt,Xslt,我的目标是根据属性匹配值筛选通知。有一个xml作为参数'privileges'输入,如下所示 <privileges> <privilege>Access my notices</privilege> <privilege>Access draft notices</privilege> <privilege>Place notice</privilege> <privilege&g

我的目标是根据属性匹配值筛选通知。有一个xml作为参数
'privileges'
输入,如下所示

<privileges>
   <privilege>Access my notices</privilege>
   <privilege>Access draft notices</privilege>
   <privilege>Place notice</privilege>
   <privilege>Access published notices</privilege>
   <privilege>Place notice of type:2903</privilege>
 <privilege>Place notice of type:2413</privilege>
 <privilege>Place notice of type:2803</privilege>
   <privilege>Access pending notices</privilege>
   <privilege>Access my account</privilege>
   <privilege>Place legacy notice</privilege>
   <privilege>Access my searches</privilege>
</privileges>
我的xslt是

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:param name="privileges" as="node()" select="doc('privileges.xml')"/>

   <xsl:variable name="codeps" select="substring-after($privileges//privilege, ':')"/> 

  <xsl:output encoding="UTF-8" indent="yes"/>

 <xsl:template match="/">
      <xsl:apply-templates/>
 </xsl:template>

<xsl:template match="notice-taxonomy">
  <notice-taxonomy>
    <xsl:for-each-group select="notice-type" group-by="@code = $codeps">

      <xsl:sequence select="." />

    </xsl:for-each-group>
  </notice-taxonomy>
</xsl:template>

</xsl:stylesheet>
如果匹配
2413

<notice-taxonomy> 
 <notice-type code="2413" level="notice" name="Royal Family" sort="02"/> 
<notice-type code="2413" level="notice" name="Change of Name and/or Arms" sort="07"/> 
</notice-taxonomy>

如果两者都匹配

<notice-taxonomy> 
 <notice-type code="2803" level="notice" name="Royal Family" sort="02"/> 
<notice-type code="2803" level="notice" name="Change of Name and/or Arms" sort="07"/> 
<notice-type code="2413" level="notice" name="Crown Office" sort="08"/> 
<notice-type code="1413" level="notice" name="Duchy of Cornwall or Duchy of Lancaster" sort="09"/> 
</notice-taxonomy>


请给我一个主意。谢谢

将变量定义为

<xsl:variable name="codeps" select="$privileges//privilege[matches(.,  ':[0-9]+$')]/substring-after(., ':')"/>

然后



<notice-taxonomy> 
 <notice-type code="2803" level="notice" name="Royal Family" sort="02"/> 
<notice-type code="2803" level="notice" name="Change of Name and/or Arms" sort="07"/> 
<notice-type code="2413" level="notice" name="Crown Office" sort="08"/> 
<notice-type code="1413" level="notice" name="Duchy of Cornwall or Duchy of Lancaster" sort="09"/> 
</notice-taxonomy>
<xsl:variable name="codeps" select="$privileges//privilege[matches(.,  ':[0-9]+$')]/substring-after(., ':')"/>
<xsl:key name="k1" match="notice-type" use="@code"/>
<xsl:template match="notice-taxonomy">
  <notice-taxonomy>
    <xsl:copy-of select="key('k1', $codeps)"/>
  </notice-taxonomy>
</xsl:template>