Я застреваю, пытаясь написать XSLT, который будет выбирать элементы с категорией «Избранные», потому что данные внутри категории обернуты в CDATA.xslt соответствует нескольким элементам, но содержит cdata
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Matched Items</h2>
<xsl:apply-templates select="//item[category/.='Featured']"/>
</body>
</html>
</xsl:template>
<xsl:template match="item">
<div class="news-item" width="100%">
<div class="news-item-description">
<xsl:value-of select="description"/>
</div>
</div>
<div class="clear" />
</xsl:template>
</xsl:stylesheet>
Образец моей информации. Это из блога wordpress, поэтому я не могу изменить вывод.
<items>
<item>
<category>
<![CDATA[ Category A ]]>
</category>
<category>
<![CDATA[ Featured ]]>
</category>
<description>This item should be in the output HTML</description>
</item>
<item>
<category>
<![CDATA[ Uncategorized ]]>
</category>
<category>
<![CDATA[ Some other category ]]>
</category>
<description>This item should NOT be in the output HTML</description>
</item>
<item>
<category>
<![CDATA[ Uncategorized ]]>
</category>
<category>
<![CDATA[ Featured ]]>
</category>
<description>This item should be in the output HTML</description>
</item>
</items>
Выход я хочу выглядеть следующим образом:
<html>
<body>
<h2>Matched Items</h2>
<div class="news-item" width="100%">
<div class="news-item-description">This item should be in the output HTML</div>
</div>
<div class="clear"></div>
<div class="news-item" width="100%">
<div class="news-item-description">This item should be in the output HTML</div>
</div>
<div class="clear"></div>
</body>
</html>
Это кажется, что это должно быть легко. Сочетание нескольких элементов категории плюс обложка CDATA застряло. Спасибо
Какой вывод вы на самом деле получаете? –