Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/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
Xml XSLT模板匹配筛选器_Xml_Xslt_Xslt 2.0 - Fatal编程技术网

Xml XSLT模板匹配筛选器

Xml XSLT模板匹配筛选器,xml,xslt,xslt-2.0,Xml,Xslt,Xslt 2.0,我能够使用下面的XSLT转换返回预期输出的XML XML <?xml version='1.0' encoding='UTF-8'?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body> <cc1:Get_Items_Response xmlns:cc1="urn:com.test/123&qu

我能够使用下面的XSLT转换返回预期输出的XML

XML

<?xml version='1.0' encoding='UTF-8'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
        <cc1:Get_Items_Response xmlns:cc1="urn:com.test/123" cc1:version="v1.0">
            
            <cc1:Response_Data>
                <cc1:Item>
                    <cc1:Item_Reference>
                        <cc1:ID cc1:type="Item_ID">12345</cc1:ID>
                    </cc1:Item_Reference>
                    <cc1:Item_Data>
                        <cc1:Item_ID>12345</cc1:Item_ID>                                                                    
                        
                        <cc1:Item_Classification_Data>
                            <cc1:Item_Classification_Reference>AAA</cc1:Item_Classification_Reference>
                            <cc1:Item_Classification_Field_Interface_Data>123</cc1:Item_Classification_Field_Interface_Data>
                        </cc1:Item_Classification_Data>
                        
                        <cc1:Item_Classification_Data>
                            <cc1:Item_Classification_Reference>BBB</cc1:Item_Classification_Reference>
                            <cc1:Item_Classification_Field_Interface_Data>456</cc1:Item_Classification_Field_Interface_Data>
                        </cc1:Item_Classification_Data>                                              
                        
                        
                    </cc1:Item_Data>
                </cc1:Item>
            </cc1:Response_Data>
        </cc1:Get_Items_Response>
    </env:Body>
</env:Envelope>


12345
12345
AAA
123
BBB
456
XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:cc1="urn:com.test/123" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    
    
    <xsl:template match="cc1:Get_Items_Response/cc1:Response_Data/cc1:Item/cc1:Item_Data/cc1:Item_Classification_Data">
        <!-- Do nothing -->
    </xsl:template>    
    
    
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template> 
</xsl:stylesheet>

输出

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
        <cc1:Get_Items_Response xmlns:cc1="urn:com.test/123" cc1:version="v1.0">

            <cc1:Response_Data>
                <cc1:Item>
                    <cc1:Item_Reference>
                        <cc1:ID cc1:type="Item_ID">12345</cc1:ID>
                    </cc1:Item_Reference>
                    <cc1:Item_Data>
                        <cc1:Item_ID>12345</cc1:Item_ID>
                    </cc1:Item_Data>
                </cc1:Item>
            </cc1:Response_Data>
        </cc1:Get_Items_Response>
    </env:Body>
</env:Envelope>
<?xml version='1.0' encoding='UTF-8'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
        <cc1:Get_Items_Response xmlns:cc1="urn:com.test/123" cc1:version="v1.0">
            
            <cc1:Response_Data>
                <cc1:Item>
                    <cc1:Item_Reference>
                        <cc1:ID cc1:type="Item_ID">12345</cc1:ID>
                    </cc1:Item_Reference>
                    <cc1:Item_Data>
                        <cc1:Item_ID>12345</cc1:Item_ID>                                                                    
                        
                        <cc1:Item_Classification_Data>
                            <cc1:Item_Classification_Reference>AAA</cc1:Item_Classification_Reference>
                            <cc1:Item_Classification_Field_Interface_Data>123</cc1:Item_Classification_Field_Interface_Data>
                        </cc1:Item_Classification_Data>                                                                                             
                        
                    </cc1:Item_Data>
                </cc1:Item>
            </cc1:Response_Data>
        </cc1:Get_Items_Response>
    </env:Body>
</env:Envelope>

12345
12345
问题:我正在尝试使用xslt将xml转换为所需的xml。任何人都可以帮助进行xslt转换。如果我想得到如下输出,我应该如何修改XSLT

问题:我正在尝试使用xslt将xml转换为所需的xml。任何人都可以帮助进行xslt转换。如果我想得到如下输出,我应该如何修改XSLT

问题:我正在尝试使用xslt将xml转换为所需的xml。任何人都可以帮助进行xslt转换。如果我想得到如下输出,我应该如何修改XSLT

问题:我正在尝试使用xslt将xml转换为所需的xml。任何人都可以帮助进行xslt转换。如果我想得到如下输出,我应该如何修改XSLT

所需输出

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
        <cc1:Get_Items_Response xmlns:cc1="urn:com.test/123" cc1:version="v1.0">

            <cc1:Response_Data>
                <cc1:Item>
                    <cc1:Item_Reference>
                        <cc1:ID cc1:type="Item_ID">12345</cc1:ID>
                    </cc1:Item_Reference>
                    <cc1:Item_Data>
                        <cc1:Item_ID>12345</cc1:Item_ID>
                    </cc1:Item_Data>
                </cc1:Item>
            </cc1:Response_Data>
        </cc1:Get_Items_Response>
    </env:Body>
</env:Envelope>
<?xml version='1.0' encoding='UTF-8'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
        <cc1:Get_Items_Response xmlns:cc1="urn:com.test/123" cc1:version="v1.0">
            
            <cc1:Response_Data>
                <cc1:Item>
                    <cc1:Item_Reference>
                        <cc1:ID cc1:type="Item_ID">12345</cc1:ID>
                    </cc1:Item_Reference>
                    <cc1:Item_Data>
                        <cc1:Item_ID>12345</cc1:Item_ID>                                                                    
                        
                        <cc1:Item_Classification_Data>
                            <cc1:Item_Classification_Reference>AAA</cc1:Item_Classification_Reference>
                            <cc1:Item_Classification_Field_Interface_Data>123</cc1:Item_Classification_Field_Interface_Data>
                        </cc1:Item_Classification_Data>                                                                                             
                        
                    </cc1:Item_Data>
                </cc1:Item>
            </cc1:Response_Data>
        </cc1:Get_Items_Response>
    </env:Body>
</env:Envelope>

12345
12345
AAA
123

试着这样写模板行

<xsl:template match="cc1:Get_Items_Response/cc1:Response_Data/cc1:Item/cc1:Item_Data/cc1:Item_Classification_Data[text()='BBB']">
    <!-- Do nothing -->
</xsl:template>    

然后使用以下命令:

<xsl:template match="cc1:Item_Classification_Data[cc1:Item_Classification_Reference[text()='BBB']]">
    <!-- Do nothing -->
</xsl:template>    


您想过滤什么?1.关于内容:AAA或BBB2。On位置:第一个或第二个cc1:Item\u Classification\u数据我要筛选完整的
cc1:Item\u Classification\u数据
节点,其中cc1:Item\u Classification\u Reference=bbb然后使用第一个答案:我假设它不适用于以下更改<代码>谢谢,但没用谢谢。完美的