Re: Selecting distinct values from different node in XPATH 1.0

enpysoft <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>
Hi Chris, 
            I here with attaching a sample XML file and the XSLT file which
is same like what i am using. Hope this could help to debug the issue. If i
am wrong please correct me.

http://www.nabble.com/file/p24721882/report.xml report.xml 
http://www.nabble.com/file/p24721882/scriptreport.xsl scriptreport.xsl 

Thanks in Advance,
npselvan.



Christoffer Dam Bruun wrote:
> 
> 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
>>>>   
>>>>       
>>>
>>>     
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Selecting-distinct-values-from-different-node-in-XPATH-1.0-tp24717305p24721882.html
Sent from the Xalan - J - Users mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.