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
使用bing api xslt_Api_Xslt_Namespaces_Bing - Fatal编程技术网

使用bing api xslt

使用bing api xslt,api,xslt,namespaces,bing,Api,Xslt,Namespaces,Bing,我正在尝试使用Bing图像api,但无法使其正常工作。 我试图转换结果,但转换不会返回任何有用的结果。 我认为这是因为我在名称空间上做了一些错误的事情,因为我发现在所有与xml相关的语言中,名称空间都非常混乱 以下是我从Bing获得的一个示例: <?xml version="1.0" encoding="utf-8" ?> <?pageview_candidate?> <SearchResponse xmlns="http://schemas.microsoft.c

我正在尝试使用Bing图像api,但无法使其正常工作。 我试图转换结果,但转换不会返回任何有用的结果。 我认为这是因为我在名称空间上做了一些错误的事情,因为我发现在所有与xml相关的语言中,名称空间都非常混乱

以下是我从Bing获得的一个示例:

<?xml version="1.0" encoding="utf-8" ?>
<?pageview_candidate?>
<SearchResponse xmlns="http://schemas.microsoft.com/LiveSearch/2008/04/XML/element" Version="2.2">
<Query>
  <SearchTerms>natalie portman</SearchTerms>
</Query>
<mms:Image xmlns:mms="http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia">
  <mms:Total>644000</mms:Total>
  <mms:Offset>0</mms:Offset>
  <mms:Results>
    <mms:ImageResult>
      <mms:Title>Natalie Portman/natalie-portman-83</mms:Title>
      <mms:MediaUrl>http://www.bestidol.pl/natalieportman/slides/natalie-portman-83.jpg</mms:MediaUrl>
      <mms:Url>http://www.bestidol.pl/natalieportman/slides/natalie-portman-83.php</mms:Url><mms:DisplayUrl>http://www.bestidol.pl/natalieportman/slides/natalie-portman-83.php</mms:DisplayUrl>
      <mms:Width>1024</mms:Width>
      <mms:Height>768</mms:Height>
      <mms:FileSize>95173</mms:FileSize>
      <mms:ContentType>image/jpeg</mms:ContentType>
      <mms:Thumbnail>
        <mms:Url>http://ts1.mm.bing.net/images/thumbnail.aspx?q=809383506038& amp;id=b829ae4c6df8866b6a07325bedca4bbd</mms:Url>
        <mms:ContentType>image/jpeg</mms:ContentType>
        <mms:Width>160</mms:Width>
        <mms:Height>120</mms:Height>
        <mms:FileSize>3838</mms:FileSize>
      </mms:Thumbnail></mms:ImageResult>
   <mms:ImageResult>
   ... other ImageResults and closing tags.

娜塔莉·波特曼
644000
0
娜塔莉·波特曼/娜塔莉·波特曼-83
http://www.bestidol.pl/natalieportman/slides/natalie-portman-83.jpg
http://www.bestidol.pl/natalieportman/slides/natalie-portman-83.phphttp://www.bestidol.pl/natalieportman/slides/natalie-portman-83.php
1024
768
95173
图像/jpeg
http://ts1.mm.bing.net/images/thumbnail.aspx?q=809383506038& amp;id=b829ae4c6df8866b6a07325bedca4bbd
图像/jpeg
160
120
3838
... 其他图像结果和结束标记。
这里是我当前的xslt转换:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:mms="http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia">

<xsl:template match="/">
<list>
   <xsl:for-each select="//mms:ImageResult" >
    <element>
        <image>
            <url><xsl:value-of select="/mms:MediaUrl" /></url>
            <width><xsl:value-of select="/mms:Width" /></width>
            <height><xsl:value-of select="/mms:Height" /></height>
        </image>
    </element>
    </xsl:for-each>
</list>
</xsl:template>

</xsl:stylesheet>

有人看到我的错误了吗? 因为此转换返回我:

<list xmlns:mms="http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia">
   <element>
     <image>
       <url/>
       <width/>
       <height/>
     </image>
   </element>
   ...
</list>

...
不应该

    <url><xsl:value-of select="mms:MediaUrl" /></url>
    <width><xsl:value-of select="mms:Width" /></width>
    <height><xsl:value-of select="mms:Height" /></height>


非常感谢,愚蠢的错误,至少我的名称空间是正确的;)