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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/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: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Header/> <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ResponseData xmlns="h

具有以下格式的输入XML:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header/>
  <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ResponseData xmlns="http://testify.com/maxi">
      <VALID>true</VALID>
      <ERROR_DESC xsi:nil="true"> something gone wrong </ERROR_DESC>
    </ResponseData>
  </s:Body>
</s:Envelope>

真的
出毛病了
由于名称空间的复杂性,将其转换为以下格式变得越来越困难

<STATUS>
  <VALID> TRUE </VALID>
  <ERROR_DESC> something gone wrong  </ERROR_DESC>
</STATUS>

真的
出毛病了
我尝试了几种选择,但都没有成功。下面没有数据

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output method="xml" encoding="utf-8" indent="no"/>
<xsl:template match="/">
  <xsl:value-of select="s:Envelope//s:Body/s:ResponseData"/>
</xsl:template>


  <xsl:template match="s:ResponseData">
    <xsl:element name="width">
      <xsl:value-of select="s:VALID"/>
    </xsl:element>
  </xsl:template>


</xsl:stylesheet>

要获得问题中指定的结果,您需要:

(a) 在寻址
ResponseData
元素及其子元素时使用正确的名称空间;和
(b) 通过对
ResponseData
的子级应用模板,实际处理它们

XSLT1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://testify.com/maxi"
exclude-result-prefixes="m">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

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

<xsl:template match="m:*">
   <xsl:element name="{local-name()}">
        <xsl:apply-templates/>
    </xsl:element>
</xsl:template>

</xsl:stylesheet>



请注意,为了不复制名称空间,没有复制任何内容。

要获得问题中指定的结果,您需要:

<STATUS>
  <VALID> TRUE </VALID>
  <ERROR_DESC> something gone wrong  </ERROR_DESC>
</STATUS>
(a) 在寻址
ResponseData
元素及其子元素时使用正确的名称空间;和
(b) 通过对
ResponseData
的子级应用模板,实际处理它们

XSLT1.0

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://testify.com/maxi"
exclude-result-prefixes="m">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

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

<xsl:template match="m:*">
   <xsl:element name="{local-name()}">
        <xsl:apply-templates/>
    </xsl:element>
</xsl:template>

</xsl:stylesheet>


请注意,为了不复制名称空间,没有复制任何内容。

如果您希望
作为包装器,那么您为什么要求
?!如果您想要
作为包装器,那么您为什么要求
?!
<STATUS>
  <VALID> TRUE </VALID>
  <ERROR_DESC> something gone wrong  </ERROR_DESC>
</STATUS>