Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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
Xml xslt中的多个匹配条件检查_Xml_Xslt - Fatal编程技术网

Xml xslt中的多个匹配条件检查

Xml xslt中的多个匹配条件检查,xml,xslt,Xml,Xslt,我有这样一个xml: <root> <p>Hellooooo world</p> <drawing> <blip embed="rId11"/> </drawing> <p>This is testing</p> <drawing> <blip embed="rId12"/> </drawing&

我有这样一个xml:

<root>
    <p>Hellooooo world</p>
    <drawing>
        <blip embed="rId11"/>
    </drawing>
    <p>This is testing</p>
    <drawing>
      <blip embed="rId12"/>
    </drawing>
    <p>This is testing2</p>
    <drawing>
        <blip embed="rId13"/>
    </drawing>
    <p>This is testing3</p>
    <part name="/word/media/image3.png" contentType="image/png" compression="store">
        <binaryData>Test1</binaryData>
    </part>
    <part name="/word/media/image4.png" contentType="image/png" compression="store">
        <binaryData>Test2</binaryData>
    </part>
    <part name="/word/media/image5.png" contentType="image/png" compression="store">
        <binaryData>Test3</binaryData>
    </part>
    <Relationship Id="rId11" Target="media/image3.png" />
    <Relationship Id="rId12" Target="media/image4.png" />
    <Relationship Id="rId13" Target="media/image5.png" />
</root>

你好世界

这是测试

这是测试2

这是测试

测试1 测试2 测试3
我对应的XSL文件如下所示:

<xsl:template match="drawing">
        <xsl:variable name="ww" select="./generate-id()"/>
        <xsl:variable name="field_id" select="//blip/@embed"/>
        <xsl:variable name="reference" select="//Relationship[@Id = $field_id]"/>
        <xsl:variable name="destination" select="//part[replace(@name,'/word/','') = $reference/@Target]"/>
        <xsl:apply-templates select="$destination/binaryData"/>
    </xsl:template>

我得到的输出是:

<root>   
<p>Hellooooo world</p>   
<binaryData>Test1</binaryData>
<binaryData>Test2</binaryData>
<binaryData>Test3</binaryData>
<p>This is testing</p>   
<binaryData>Test1</binaryData>
<binaryData>Test2</binaryData>
<binaryData>Test3</binaryData> 
<p>This is testing2</p>
<binaryData>Test1</binaryData>
<binaryData>Test2</binaryData>
<binaryData>Test3</binaryData>
<p>This is testing3</p>
</root>

你好世界

测试1 测试2 测试3 这是测试

测试1 测试2 测试3 这是测试2

测试1 测试2 测试3 这是测试

在用上面的代码转换之后,我得到了重复的内容,我希望类似的内容也会出现。 我的预期产出是:

<root>
<p>Hellooooo world</p>
<drawing>
<binarydata>Test1</binarydata>
</drawing>
<p>This is testing</p>
<drawing>
<binarydata>Test2</binarydata>
</drawing>
<p>This is testing2</p>
<drawing>
<binarydata>Test3</binarydata>
</drawing>
<p>This is testing3</p>
</root>

你好世界

测试1 这是测试

测试2 这是测试2

测试3 这是测试

有人能帮我做这件事吗

<xsl:variable name="field_id" select="//blip/@embed"/>


<xsl:variable name="field_id" select="blip/@embed"/>