无法从下面提到的 xml 中检索聚合值
Unable to retrieve aggregationValue from below mentioned xml
<ContentItem xmlns="http://endeca.com/schema/content/2008" type="GenericMarketingContent">
<TemplateId>OneRecordBanner</TemplateId>
<Name>One Record Banner</Name>
<Property name="title">
<String>Recommended</String>
</Property>
<Property name="image">
<String>green.gif</String>
</Property>
<Property name="alt_text">
<String>Image Alt text</String>
</Property>
<Property name="record_list">
<RecordSelection xmlns="http://endeca.com/schema/content/xtags/2010">
<RecordList>
<Record key="pp500231036301401000091" aggregationKey="grp_id">
<aggregationValue>pp5002310363</aggregationValue>
<label>Deer Stags Manager Mens Slip On Shoes</label>
</Record>
</RecordList>
<recordLimit>1</recordLimit>
</RecordSelection>
</Property>
</ContentItem>
/ContentItem/Property[@name='record_list']/RecordSelection/RecordList/Record/aggregationValue/text()
未获取值。我能够获得其他 属性 标签的所有其他值,但不是这个 one.Can 有人告诉我哪里错了吗?
元素 RecordSelection
及其后代与 XML 文档的其余部分位于不同的命名空间中。
如果你使用的是 xslt 2.0,你可以使用这个 xpath:
/ContentItem/Property[@name='record_list']/*:RecordSelection/*:RecordList/*:Record/*:aggregationValue
一个(可能更干净的)解决方案是使用前缀声明命名空间,这样您就可以使用这个 xpath:
/w1:ContentItem/w1:Property[@name='record_list']/w2:RecordSelection/w2:RecordList/w2:Record/w2:aggregationValue
w1
是 http://endeca.com/schema/content/2008
的前缀,w2
是 http://endeca.com/schema/content/xtags/2010
的前缀
(注意不需要最后的/text()
)
RecordSelection 及其子项位于不同的命名空间中,您没有考虑到这一点。
修复此问题的丑陋黑客版本将涉及大量本地名称调用。优雅的版本是在 XSLT 中定义名称空间。
<ContentItem xmlns="http://endeca.com/schema/content/2008" type="GenericMarketingContent">
<TemplateId>OneRecordBanner</TemplateId>
<Name>One Record Banner</Name>
<Property name="title">
<String>Recommended</String>
</Property>
<Property name="image">
<String>green.gif</String>
</Property>
<Property name="alt_text">
<String>Image Alt text</String>
</Property>
<Property name="record_list">
<RecordSelection xmlns="http://endeca.com/schema/content/xtags/2010">
<RecordList>
<Record key="pp500231036301401000091" aggregationKey="grp_id">
<aggregationValue>pp5002310363</aggregationValue>
<label>Deer Stags Manager Mens Slip On Shoes</label>
</Record>
</RecordList>
<recordLimit>1</recordLimit>
</RecordSelection>
</Property>
</ContentItem>
/ContentItem/Property[@name='record_list']/RecordSelection/RecordList/Record/aggregationValue/text()未获取值。我能够获得其他 属性 标签的所有其他值,但不是这个 one.Can 有人告诉我哪里错了吗?
元素 RecordSelection
及其后代与 XML 文档的其余部分位于不同的命名空间中。
如果你使用的是 xslt 2.0,你可以使用这个 xpath:
/ContentItem/Property[@name='record_list']/*:RecordSelection/*:RecordList/*:Record/*:aggregationValue
一个(可能更干净的)解决方案是使用前缀声明命名空间,这样您就可以使用这个 xpath:
/w1:ContentItem/w1:Property[@name='record_list']/w2:RecordSelection/w2:RecordList/w2:Record/w2:aggregationValue
w1
是 http://endeca.com/schema/content/2008
的前缀,w2
是 http://endeca.com/schema/content/xtags/2010
(注意不需要最后的/text()
)
RecordSelection 及其子项位于不同的命名空间中,您没有考虑到这一点。
修复此问题的丑陋黑客版本将涉及大量本地名称调用。优雅的版本是在 XSLT 中定义名称空间。