我正在做一些XSLT - 在一种情况下,我有一个序列化为XML文件的服务,我的XSLT将拉动它。在另一种情况下,我有一个webservice序列化相同的对象。据我所知,输出是相同的。但XML文件的XQuery / XPath不适用于XML REST服务。
例如,请查看此图片,该图片显示我从两个来源加载文档并为每个文档评估相同的路径。
这些有何不同?为什么他们不评价相同的?
更新
文件中的XML:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfBusinessGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<BusinessGroup>
<ListofSkills>
<SkillClass>
<SkillName>DTE</SkillName>
<InteractionCount>0</InteractionCount>
</SkillClass>
<SkillClass>
<SkillName>FIN</SkillName>
<InteractionCount>0</InteractionCount>
</SkillClass>
<SkillClass>
<SkillName>DPS</SkillName>
<InteractionCount>0</InteractionCount>
</SkillClass>
<SkillClass>
<SkillName>PPD Apps</SkillName>
<InteractionCount>0</InteractionCount>
</SkillClass>
<SkillClass>
<SkillName>FHD New</SkillName>
<InteractionCount>0</InteractionCount>
</SkillClass>
<SkillClass>
<SkillName>FHD Existing</SkillName>
<InteractionCount>0</InteractionCount>
</SkillClass>
</ListofSkills>
<GroupName>Apps Chat</GroupName>
</BusinessGroup>
来自Web服务的XML:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ArrayOfBusinessGroup xmlns="http://schemas.datacontract.org/2004/07/ININ.WCF.DeloitteSIC.Models" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<BusinessGroup>
<GroupName>Apps Chat</GroupName>
<ListofSkills>
<SkillClass>
<InteractionCount>2</InteractionCount>
<SkillName>DTE</SkillName>
</SkillClass>
<SkillClass>
<InteractionCount>0</InteractionCount>
<SkillName>FIN</SkillName>
</SkillClass>
<SkillClass>
<InteractionCount>0</InteractionCount>
<SkillName>DPS</SkillName>
</SkillClass>
<SkillClass>
<InteractionCount>0</InteractionCount>
<SkillName>PPD Apps</SkillName>
</SkillClass>
<SkillClass>
<InteractionCount>0</InteractionCount>
<SkillName>FHD New</SkillName>
</SkillClass>
<SkillClass>
<InteractionCount>0</InteractionCount>
<SkillName>FHD Existing</SkillName>
</SkillClass>
</ListofSkills>
</BusinessGroup>
答案 0 :(得分:1)
这里的问题是从webservice返回的XML使用名称空间,但是你的XPath不是。要正确使用名称空间,您需要:
在XSLT的顶部声明命名空间(在xsl:stylesheet标记中):
xmlns:dc="http://schemas.datacontract.org/2004/07/ININ.WCF.DeloitteSIC.Models"
然后,不是仅通过名称引用元素,而是在名称前加上声明的前缀:
$skillFile/dc:ArrayOfBusinessGroup/*[starts-with(dc:GroupName, $groupName)]