Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.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/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
xpath无法处理源xml中的名称空间_Xml_Xslt_Xpath - Fatal编程技术网

xpath无法处理源xml中的名称空间

xpath无法处理源xml中的名称空间,xml,xslt,xpath,Xml,Xslt,Xpath,我有一个简单的xpath,这是因为源xml中存在名称空间,这不起作用。我编写xpath的工具没有任何用宿主语言(包括库)编写代码的功能。我有写XSLT的能力,但不知道该怎么做,有人能帮我吗 <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" x

我有一个简单的xpath,这是因为源xml中存在名称空间,这不起作用。我编写xpath的工具没有任何用宿主语言(包括库)编写代码的功能。我有写XSLT的能力,但不知道该怎么做,有人能帮我吗

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="https://collaboration.merck.com/sites/amseimcts/_api/">
   <id>d38a1da2-02e9-467e-b59b-e520c8607914</id>
   <title />
   <updated>2019-05-08T10:54:04Z</updated>
   <entry>
      <id>https://collaboration.xxx.com/sites/amseimcts/_api/Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared Documents/SAP Config/OBA1.csv')</id>
      <category term="SP.File" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link rel="edit" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" type="application/atom+xml;type=entry" title="Author" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/Author" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CheckedOutByUser" type="application/atom+xml;type=entry" title="CheckedOutByUser" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/CheckedOutByUser" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/EffectiveInformationRightsManagementSettings" type="application/atom+xml;type=entry" title="EffectiveInformationRightsManagementSettings" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/EffectiveInformationRightsManagementSettings" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/InformationRightsManagementSettings" type="application/atom+xml;type=entry" title="InformationRightsManagementSettings" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/InformationRightsManagementSettings" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ListItemAllFields" type="application/atom+xml;type=entry" title="ListItemAllFields" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/ListItemAllFields" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/LockedByUser" type="application/atom+xml;type=entry" title="LockedByUser" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/LockedByUser" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ModifiedBy" type="application/atom+xml;type=entry" title="ModifiedBy" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/ModifiedBy" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Properties" type="application/atom+xml;type=entry" title="Properties" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/Properties" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/VersionEvents" type="application/atom+xml;type=feed" title="VersionEvents" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/VersionEvents" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Versions" type="application/atom+xml;type=feed" title="Versions" href="Web/GetFileByServerRelativePath(decodedurl='/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv')/Versions" />
      <title />
      <updated>2019-05-08T10:54:04Z</updated>
      <author>
         <name />
      </author>
      <content type="application/xml">
         <m:properties>
            <d:CheckInComment />
            <d:CheckOutType m:type="Edm.Int32">2</d:CheckOutType>
            <d:ContentTag>{87637609-7D7C-466B-A60B-5BD7A028712C},6,6</d:ContentTag>
            <d:CustomizedPageStatus m:type="Edm.Int32">0</d:CustomizedPageStatus>
            <d:ETag>"{87637609-7D7C-466B-A60B-5BD7A028712C},6"</d:ETag>
            <d:Exists m:type="Edm.Boolean">true</d:Exists>
            <d:IrmEnabled m:type="Edm.Boolean">false</d:IrmEnabled>
            <d:Length m:type="Edm.Int64">447</d:Length>
            <d:Level m:type="Edm.Byte">1</d:Level>
            <d:LinkingUri>https://collaboration.merck.com/sites/amseimcts/Shared%20Documents/SAP%20Config/OBA1.csv?d=w876376097d7c466ba60b5bd7a028712c</d:LinkingUri>
            <d:LinkingUrl>https://collaboration.merck.com/sites/amseimcts/Shared Documents/SAP Config/OBA1.csv?d=w876376097d7c466ba60b5bd7a028712c</d:LinkingUrl>
            <d:MajorVersion m:type="Edm.Int32">4</d:MajorVersion>
            <d:MinorVersion m:type="Edm.Int32">0</d:MinorVersion>
            <d:Name>OBA1.csv</d:Name>
            <d:ServerRelativeUrl>/sites/amseimcts/Shared Documents/SAP Config/OBA1.csv</d:ServerRelativeUrl>
            <d:TimeCreated m:type="Edm.DateTime">2019-05-05T10:50:02Z</d:TimeCreated>
            <d:TimeLastModified m:type="Edm.DateTime">2019-05-07T12:08:57Z</d:TimeLastModified>
            <d:Title m:null="true" />
            <d:UIVersion m:type="Edm.Int32">2048</d:UIVersion>
            <d:UIVersionLabel>4.0</d:UIVersionLabel>
            <d:UniqueId m:type="Edm.Guid">87637609-7d7c-466b-a60b-5bd7a028712c</d:UniqueId>
         </m:properties>
      </content>
   </entry>
</feed>

更新xpath,如下所示:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:atom="http://www.w3.org/2005/Atom" 
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
version="1.0">

<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />

<xsl:template match="/">
    <xsl:value-of select="atom:feed/atom:entry/atom:content/m:properties/d:Name" />
</xsl:template>

</xsl:stylesheet>


请参见此处的演示:

在将前缀绑定到XML中使用的名称空间后,您需要使用前缀。您应该询问您的问题。因此,投反对票的人可以回答这个问题。我认为这是一个一般性的答案。你也可以用这个。不管怎样,你的答案很好。谢谢。)现在我明白了一些事情。但还是有疑问。你要求我更新xpath。但是您给出的是xslt,所以这只能使用xslt来完成?您没有提到XPATH使用的工具。您还提到您有编写xslt的工具。不是吗?
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:atom="http://www.w3.org/2005/Atom" 
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
version="1.0">

<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*" />

<xsl:template match="/">
    <xsl:value-of select="atom:feed/atom:entry/atom:content/m:properties/d:Name" />
</xsl:template>

</xsl:stylesheet>