That kind of errors are never nice....

If the problem is that set:distinct is returning a resulttree-fragment then
it might help wrapping the variable in common:node-set() before using it e.g.; <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
   xmlns:common="http://exslt.org/common";
   ... >
...
<xsl:for-each select="common:node-set($var-returned-by-distinct-function)">
....
<xsl:for-each>



Best regards
Christoffer Dam Bruun

enpysoft skrev:
Hi Chris,
            I am new to XSLT programming. Thanks for your reference. I did
as like you said. But i get some exception like this
java.lang.reflect.InvocationTargetException when i traverse loop the
variable i stored the distinct values. So can you suggest me if i did
anything wrong. But when i created the variable and not referred anywhere
the variable it is not causing the problem. This exception is thrown when i
am using the variable to loop through using xsl:for-each. Can you help me
how to resolve this kind of issue.

Thanks in Advance,
npselvan

Christoffer Dam Bruun wrote:
Hi Npselval,

Is it impossible for you to use the exslt.org extensions (they are part of xalan you should just declare the namespace).
They contain an implementation of the distinct function. Example:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
    xmlns:set="http://exslt.org/sets";>

<xsl:variable name="uniquevalues"
select="set:distinct(/validation/report/script/case/@name)"
/>

...


Best regards
Christoffer Dam Bruun

enpysoft skrev:
Hi Experts,
          I have to get the list of the distinct attribute values across
different node level. To help you understand my requirement, i am
herewith
listed with a sample XML file

My XML file looks like this

<validation>
 <report>
   <script city="NY">
          <case name="ramesh" status="BE"/>
          <case name="rajesh" status="B.Com" />
   </script>
   <script city="AL">
          <case name="ramesh" status="Law" />
   </script>
 </report>
</validation>

Now i have to get only the values as ramesh and rajesh and i should not
get
ramesh two times. As i use only XPATH 1.0 and XSLT 1.0 i cannot use
distinct-values function. I earlier tried using to fetch distinct values
to
a variable using the below script in xslt and it is not working.

<xsl:variable name="uniquevalues"
select="/validation/report/script/case[not(@name=predicate-sibling::validation/report/script/case/@name)]/@name"
/>

The above code snippet is not working. Kindly let me know what has to be
done to get my expected output.


thanks in advance,
npselvan



Reply via email to