从SOAP响应中,我收到了以下XML:
<?xml version="1.0" encoding="UTF-8"?>
<FindRelativesResponse xmlns="http://avid.com/interplay/ws/assets/types">
<Results>
<AssetDescription>
<InterplayURI>interplay://avideng103?mobid=060a2b340101010101010f0013-000000-53f2ae93b07200c3-060e2b347f7f-2a80</InterplayURI>
<Attributes>
<Attribute Name="MOB ID" Group="SYSTEM">060a2b340101010101010f0013-000000-53f2ae93b07200c3-060e2b347f7f-2a80</Attribute>
<Attribute Name="Moniker" Group="SYSTEM">1|F9E3A1A4-4CB9-45CC-A590-77A5D733B633|*|1121558|*</Attribute>
</Attributes>
</AssetDescription>
<AssetDescription>
<InterplayURI>interplay://avideng103?mobid=060a2b340101010101010f0013-000000-568ad56218ad42e7-060e2b347f7f-2a80</InterplayURI>
<Attributes>
<Attribute Name="MOB ID" Group="SYSTEM">060a2b340101010101010f0013-000000-568ad56218ad42e7-060e2b347f7f-2a80</Attribute>
<Attribute Name="Moniker" Group="SYSTEM">1|F9E3A1A4-4CB9-45CC-A590-77A5D733B633|*|4229098|*</Attribute>
<Attribute Name="CATDV RemoteID" Group="USER">11868</Attribute>
<Attribute Name="CATDV Animal" Group="USER">Tortoise</Attribute>
<Attribute Name="CATDV Director Approved" Group="USER">Director Approved</Attribute>
<Attribute Name="CATDV Location" Group="USER">Land</Attribute>
<Attribute Name="CATDV Time of Day" Group="USER">Day</Attribute>
</Attributes>
</AssetDescription>
</Results>
</FindRelativesResponse>然而,我在这方面的正常尝试并没有奏效。我试过以下几种方法:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:template match = "/">
<test>
<xsl:value-of select="FindRelativesResponse/Results/AssetDescription/Attributes/Attribute[@Name = 'CATDV RemoteID']"/>
</test>
</xsl:template>
</xsl:stylesheet>但是,测试元素中的结果将是空的。
我想知道这是否与此有关:<FindRelativesResponse xmlns="http://avid.com/interplay/ws/assets/types">,我不习惯看到这一点,所以我想知道在xslt中是否遗漏了一个步骤。
以下是帮助回答问题所需的更多信息。我有多个名称空间,并且不知道如何使它们像上面所列出的那样正常工作。以下是我到目前为止尝试过的,特别是在第4期<soa:Parameter>上列出的内容:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:avid="http://avid.com/interplay/ws/assets/types"
xmlns:soa="urn:telestream.net:soa:core"
exclude-result-prefixes="avid"
version="1.0">
<xsl:template match = "/">
<soa:Label>
<soa:Parameter type="string" identifier="7c0c6642-5a4d-42b7-9945-303caffd2c57" bindable="True" name="CATDV Time of Day" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="ced9fe1e-d546-4b2e-9dd8-4ad94d701802" bindable="True" name="CATDV Director Approved" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="16aba128-da36-4e3e-b68a-b95792b15be8" bindable="True" name="CATDV Location" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="930630e1-7697-4514-9aa4-d00d536db664" bindable="True" name="CATDV Animal" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="6a2319d4-4894-4268-8f71-186c2b8cf39a" bindable="True" name="CATDV Remote ID" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1"><xsl:value-of select= "avid:FindRelativesResponse/avid:Results/avid:AssetDescription/avid:Attributes/avid:Attribute[@Name = 'CATDV Remote ID']"></xsl:value-of>
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="7a05829d-0a73-4cf0-a075-ef4d26f95c2a" bindable="True" name="Reference Asset MOB ID" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
</soa:Label>
</xsl:template>
</xsl:stylesheet>发布于 2016-01-12 17:18:13
我想知道这是否与此有关:
<FindRelativesResponse xmlns="http://avid.com/interplay/ws/assets/types">
当然有了。这样试一试:
-编辑以适应新添加的需求:--
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soa="urn:telestream.net:soa:core"
xmlns:avid="http://avid.com/interplay/ws/assets/types"
exclude-result-prefixes="avid">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<soa:Label>
<soa:Parameter type="string" identifier="7c0c6642-5a4d-42b7-9945-303caffd2c57" bindable="True" name="CATDV Time of Day" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="ced9fe1e-d546-4b2e-9dd8-4ad94d701802" bindable="True" name="CATDV Director Approved" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="16aba128-da36-4e3e-b68a-b95792b15be8" bindable="True" name="CATDV Location" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="930630e1-7697-4514-9aa4-d00d536db664" bindable="True" name="CATDV Animal" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="6a2319d4-4894-4268-8f71-186c2b8cf39a" bindable="True" name="CATDV Remote ID" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<xsl:value-of select="avid:FindRelativesResponse/avid:Results/avid:AssetDescription/avid:Attributes/avid:Attribute[@Name = 'CATDV RemoteID']"/>
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
<soa:Parameter type="string" identifier="7a05829d-0a73-4cf0-a075-ef4d26f95c2a" bindable="True" name="Reference Asset MOB ID" enabled="true" disableable="false" optionseditable="false" row="-1" column="-1" columnspan="1">
<soa:IsRequired>false</soa:IsRequired>
</soa:Parameter>
</soa:Label>
</xsl:template>
</xsl:stylesheet>https://stackoverflow.com/questions/34749804
复制相似问题