Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 1.0 筛选出没有响应的键_Xslt 1.0 - Fatal编程技术网

Xslt 1.0 筛选出没有响应的键

Xslt 1.0 筛选出没有响应的键,xslt-1.0,Xslt 1.0,我有一个xslt表,其中有两个响应对象$response1包含一个ID列表,类似于: <response> <idlist> <id>1</id> <id>2</id> </idlist> </response> $response2包含许多对象: <response2> <obj id="1" name="obj1"/> <obj id

我有一个xslt表,其中有两个响应对象$response1包含一个ID列表,类似于:

<response>
  <idlist>
    <id>1</id>
    <id>2</id>
  </idlist>
</response>
$response2包含许多对象:

<response2>
  <obj id="1" name="obj1"/>
  <obj id="2" name="obj2"/>
  <obj id="3" name="obj3"/>
  <obj id="4" name="obj4"/>
</response2>
我想复制response2,但过滤掉id与Response1中包含的thos匹配的任何对象

<xsl:variable name="copy">
  <xsl:copy-of select="$response2/*[not contains($response1, id)]"/>
</xsl:variable>
有什么好主意吗 C

给定格式良好的输入,例如:

<root>
  <response>
    <idlist>
      <id>1</id>
      <id>2</id>
    </idlist>
  </response>
  <response2>
    <obj id="1" name="obj1"/>
    <obj id="2" name="obj2"/>
    <obj id="3" name="obj3"/>
    <obj id="4" name="obj4"/>
  </response2>
</root>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/root">
    <xsl:variable name="ids" select="response/idlist/id" />
    <output>
        <xsl:copy-of select="response2/obj[not(@id=$ids)]"/>
    </output>
</xsl:template>

</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<output>
   <obj id="3" name="obj3"/>
   <obj id="4" name="obj4"/>
</output>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:key name="id" match="id" use="." />

<xsl:template match="/root">
    <output>
        <xsl:copy-of select="response2/obj[not(key('id', @id))]"/>
    </output>
</xsl:template>

</xsl:stylesheet>