Hi All,
Can some one please guide me on the distinct values.
In my xslt at one point need to get distinct supplier values.
Below is sample xml of supplier info
<SupplierXitem><XItemSupDesc xmlns:ns3="http://xmlns.oracle.com/TSS_to_RMS/RIBXItemProcess/SupplierXitem" xmlns="http://xmlns.oracle.com/TSS_to_RMS/RIBXItemProcess/SupplierXitem"><ns3:XitemSup><ns3:supplier>101018</ns3:supplier><ns3:primary_supp_ind>N</ns3:primary_supp_ind><ns3:XitemSupCtydesc><ns3:origin_country_id>IN</ns3:origin_country_id><ns3:primary_country_ind>Y</ns3:primary_country_ind><ns3:unit_cost>6.000000</ns3:unit_cost></ns3:XitemSupCtydesc></ns3:XitemSup><ns3:XitemSup><ns3:supplier>101018</ns3:supplier><ns3:primary_supp_ind>N</ns3:primary_supp_ind><ns3:XitemSupCtydesc><ns3:origin_country_id>CA</ns3:origin_country_id><ns3:primary_country_ind>Y</ns3:primary_country_ind><ns3:unit_cost>7.000000</ns3:unit_cost></ns3:XitemSupCtydesc></ns3:XitemSup></XItemSupDesc></SupplierXitem>
and my outputshould be as below
<ns1:XItemSupDesc>
<ns1:supplier>101018</ns1:supplier><ns1:primary_supp_ind>N</ns1:primary_supp_ind>
<ns1:XItemSupCtyDesc>
<ns1:origin_country_id>CN</ns1:origin_country_id><ns1:primary_country_ind>Y</ns1:primary_country_ind><ns1:unit_cost>7.000000</ns1:unit_cost></ns1:XItemSupCtyDesc>
<ns1:XItemSupCtyDesc>
<ns1:XItemSupCtyDesc><ns1:origin_country_id>IN</ns1:origin_country_id><ns1:primary_country_ind>Y</ns1:primary_country_ind><ns1:unit_cost>6.000000</ns1:unit_cost></ns1:XItemSupCtyDesc>
</XItemSupDesc>
Here is my loigc from the of xslt code
<xsl:for-each select="fn:distinct-values($supplier/ns2:XItemSupDesc/ns2:XitemSup/ns2:supplier)">
<xsl:variable name="DistinctSupplier" select="."/>
<ns1:XItemSupDesc>
<ns1:supplier>
<xsl:value-of select="."/>
</ns1:supplier>
<ns1:primary_supp_ind>
<xsl:value-of select="../ns2:primary_supp_ind"/>
</ns1:primary_supp_ind>
<ns1:vpn>
<xsl:value-of select="/ns1:XItemDesc/ns1:XItemSupDesc/ns1:vpn"/>
</ns1:vpn>
<xsl:for-each select="..">
<xsl:if test="ns2:supplier = $DistinctSupplier">
<ns1:XItemSupCtyDesc>
<ns1:origin_country_id>
<xsl:value-of select="ns2:origin_country_id"/>
</ns1:origin_country_id>
<ns1:primary_country_ind>
<xsl:value-of select="ns2:primary_country_ind"/>
</ns1:primary_country_ind>
<ns1:unit_cost>
<xsl:value-of select="ns2:unit_cost"/>
</ns1:unit_cost>
</ns1:XItemSupCtyDesc>
</xsl:if>
</xsl:for-each>
</XItemSupDesc>
I have gone couple of solution in the forum regarding distinct values but i could make it as i am getting runtime error as below
XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is ora:doXSLTransformForDoc('xsl/Trans_Soa_Supplier_XitemDesc.xsl', $XitemDesc, 'supplier', $supplier). The XPath expression failed to execute; the reason was: javax.xml.transform.TransformerException: XML-22900: (Fatal Error)
it would be great if some one helps me
Regards,
Tarak.