my xml is as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="document-library-filter.xsl"?>
<xml total="14">
<document>
<file_type><![CDATA[application/pdf]]></file_type>
<file_size><![CDATA[4420 KB]]></file_size>
<document_group><![CDATA[LED Systems 1]]></document_group>
</document>
<document>
<file_type><![CDATA[application/pdf]]></file_type>
<file_size><![CDATA[4420 KB]]></file_size>
<document_group><![CDATA[LED Systems 1]]></document_group>
</xml>
it contains multiple document node. and each document node has file type node. value is pdf for all document nodes. i want to write out single file type node. and discard other nodes as they has same values. to do that i try to write out following xslt. but it writes out all the nodes.
following is the xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<hr class="grid-hr inner-grid"/>
<fieldset>
<legend>%%filter-file-types%%:</legend>
<ul class="itembrowser-filter">
<xsl:for-each select="xml/document">
<xsl:if test="file_type">
<xsl:variable name="file_type">
<xsl:value-of select="file_type"/>
</xsl:variable>
<xsl:variable name="file_type_Value">
<xsl:value-of select="substring-after($file_type,'/')"/>
</xsl:variable>
<li>
<label>
<input type="checkbox" class="input-big-checkbox" name="filetype-filter" value="{$file_type}"/>
<span class="label"><xsl:copy-of select="$file_type_Value" /></span>
</label>
</li>
</xsl:if>
</xsl:for-each>
</ul>
</fieldset>
<hr class="grid-hr inner-grid"/>
</xsl:template>
i need some way to compare both the node values and if they are same then it will write out only once.
my expected output is:
<fieldset>
<legend>%%filter-file-types%%:</legend>
<ul class="itembrowser-filter">
<li>
<label>
<input type="checkbox" class="input-big-checkbox" name="filetype-filter" value="application/pdf"/>
<span class="label"><xsl:copy-of select="pdf" /></span>
</label>
</li>
</ul>
</fieldset>
i am not able to achieve this. please help me out.
No comments:
Post a Comment