Project

Profile

Help

Getting Duplicate Definition of Function Error when processing XQuery code with Saxon 8 in Java

Added by Arvind IK Chari almost 11 years ago

Hi

I am trying to do some XQuery processing using Priscilla Walmsley's FunctX Library(functx.com) and I am getting this error--

Error on line 2358 column 4 of http://546182fdd5275b6ead42-df5c28cde33ae816a8b86 35168ae3631.r97.cf1.rackcdn.com/functx-1.0.xq: XQST0034: XQuery static error in #...im the delimiter :) declare#: Duplicate definition of function substring-after-match (see line 2353 in http://546182fdd5275b6ead42-df5c28cde33ae816a8b8635168ae3631.r97.cf1.rackcdn.c om/functx-1.0.xq) Error on line 2376 column 4 of http://546182fdd5275b6ead42-df5c28cde33ae816a8b86 35168ae3631.r97.cf1.rackcdn.com/functx-1.0.xq: XQST0034: XQuery static error in #...gular expression :) declare#: Duplicate definition of function substring-before-if-contains (see line 2369 in http://546182fdd5275b6ead42-df5c28cde33ae816a8b8635168ae3631.r97.cf1.rackcdn.c om/functx-1.0.xq)

Basically there is a long list of Duplicate definition of function errors in the output.

What am I doing wrong here

I am using the functx Library with my own XQuery code- and the functions listed above are defined exactly once(in both my code and the functx library).

Thanks, Arvind.


Replies (5)

Please register to reply

RE: Getting Duplicate Definition of Function Error when processing XQuery code with Saxon 8 in Java - Added by Michael Kay almost 11 years ago

First, check to see if you are importing the functx module more than once. This should be OK, provided you use exactly the same URI.

Secondly, check to see what Saxon version you are using. "Saxon 8" describes a range of versions from Saxon 8.0 produced around 2004 to Saxon 8.9 produced in February 2007, just after the XQuery 1.0 specification became stable. The current release is 9.5, and very many bugs have been fixed in the intervening time.

RE: Getting Duplicate Definition of Function Error when processing XQuery code with Saxon 8 in Java - Added by Arvind IK Chari almost 11 years ago

Hi

I tried again with Saxon 9 but still getting same errors?

Also there was a slight mistake in my previous post- I have 2 XQuery files being invoked by a piece of XQuery code. One XQuery file invokes Functx, and the small piece of code invokes the first XQUery file.

FOr reference, given below is the first XQuery file's entire code-

(:~ : ------------------------------------------ : The Crawler XQuery Function Library : ------------------------------------------

: Copyright (C) 2012 Arvind I K Chari

: @version 1.1

:) module namespace xyz= "http://www.xyz.com" ;

(:~ : Resolves first name, middle name, and last name from combined String : : @author Arvind I K Chari, Anya Services : @version 1.0 : @see http://www.anyaservices.com/ : @param $wholename the name in this format FIRST_NAME MIDDLE_NAME LAST_NAME : @param $delimiter the delimiter with which to separate the first, middle and last names :) import module namespace functx = "http://www.functx.com" at "http://546182fdd5275b6ead42-df5c28cde33ae816a8b8635168ae3631.r97.cf1.rackcdn.com/functx-1.0.xq";

declare function anyacrawler:resolvename ( $wholename as xs:string , $delimiter as xs:string ) as xs:string {

   let $first_name:= substring-before($wholename, ' ')
   let $remaining_name:= substring-after($wholename, ' ')
   return
   	 if( contains($remaining_name, ' '))
     then let $last_name:= functx:substring-after-last($remaining_name, ' ')
        let $middle_name:= functx:substring-before-last($remaining_name, ' ')
            let $result:= concat($first_name, $delimiter, $middle_name, $delimiter, $last_name)
            return $result
   	 else let $last_name:= $remaining_name
   	 	let $middle_name:= '' 
    	let $result:= concat($first_name, $delimiter, $middle_name, $delimiter, $last_name)
    	return $result

};

(:~ : Gets date in format yyyymmdd from format MMM dd,yyyy : : @author Arvind I K Chari, Anya Services : @version 1.1 : @see http://www.anyaservices.com/ : @param $original_date Date in this format "Sep 12, 1997" (excluding quotes) : @result date in this format-- "19970912" (excluding quotes) :) declare function anyacrawler:dateconverter1($orig_date as xs:string) as xs:string { let $original_date:= $orig_date let $month:= substring($original_date, 1,3) return if($original_date='') then let $result:= '' return $result else if(string-length($original_date)=4) then let $result:= concat($original_date, '0000') return $result else if($month= 'Jan') then let $mon:='01' let $month_and_dd:= substring-before($original_date, ',') let $dd:= substring-after($month_and_dd, ' ') let $year_with_space:= substring-after($original_date, ',') let $year:= replace($year_with_space, ' ', '') return if(string-length($dd)=1) then let $date_req:= concat('0', $dd) let $result:= concat($year, $mon, $date_req) return $result else let $date_req := $dd let $result:= concat($year, $mon, $date_req) return $result else if($month= 'Feb') then let $mon:='02' let $month_and_dd:= substring-before($original_date, ',') let $dd:= substring-after($month_and_dd, ' ') let $year_with_space:= substring-after($original_date, ',') let $year:= replace($year_with_space, ' ', '') return if(string-length($dd)=1) then let $date_req:= concat('0', $dd) let $result:= concat($year, $mon, $date_req) return $result else let $date_req := $dd let $result:= concat($year, $mon, $date_req) return $result else if($month= 'Mar') then let $mon:='03' let $month_and_dd:= substring-before($original_date, ',') let $dd:= substring-after($month_and_dd, ' ') let $year_with_space:= substring-after($original_date, ',') let $year:= replace($year_with_space, ' ', '') return if(string-length($dd)=1) then let $date_req:= concat('0', $dd) let $result:= concat($year, $mon, $date_req) return $result else let $date_req := $dd let $result:= concat($year, $mon, $date_req) return $result else if($month= 'Apr') then let $mon:='04' let $month_and_dd:= substring-before($original_date, ',') let $dd:= substring-after($month_and_dd, ' ') let $year_with_space:= substring-after($original_date, ',') let $year:= replace($year_with_space, ' ', '') return if(string-length($dd)=1) then let $date_req:= concat('0', $dd) let $result:= concat($year, $mon, $date_req) return $result else let $date_req := $dd let $result:= concat($year, $mon, $date_req) return $result else if($month= 'May') then let $mon:='05' let $month_and_dd:= substring-before($original_date, ',') let $dd:= substring-after($month_and_dd, ' ') let $year_with_space:= substring-after($original_date, ',') let $year:= replace($year_with_space, ' ', '') return if(string-length($dd)=1) then let $date_req:= concat('0', $dd) let $result:= concat($year, $mon, $date_req) return $result else let $date_req := $dd let $result:= concat($year, $mon, $date_req) return $result

  		else if($month= 'Jun')  then
  			let $mon:='06'
  			let $month_and_dd:= substring-before($original_date, ',')
  			let $dd:= substring-after($month_and_dd, ' ')
  			let $year_with_space:= substring-after($original_date, ',')
     		let $year:= replace($year_with_space, ' ', '')
  			return 
  			    if(string-length($dd)=1) then
     			let $date_req:= concat('0', $dd)
     			let $result:= concat($year, $mon, $date_req)
     			return $result
     		    else 
     			let $date_req := $dd
     			let $result:= concat($year, $mon, $date_req)
         			return $result
  		else if($month= 'Jul')  then
  			let $mon:='07'
  			let $month_and_dd:= substring-before($original_date, ',')
  			let $dd:= substring-after($month_and_dd, ' ')
  			let $year_with_space:= substring-after($original_date, ',')
     		let $year:= replace($year_with_space, ' ', '')
  			return 
  			    if(string-length($dd)=1) then
     			let $date_req:= concat('0', $dd)
     			let $result:= concat($year, $mon, $date_req)
     			return $result
     		    else 
     			let $date_req := $dd
     			let $result:= concat($year, $mon, $date_req)
         			return $result
  		else if($month= 'Aug')  then
  			let $mon:='08'
  			let $month_and_dd:= substring-before($original_date, ',')
  			let $dd:= substring-after($month_and_dd, ' ')
  			let $year_with_space:= substring-after($original_date, ',')
     		let $year:= replace($year_with_space, ' ', '')
  			return 
  			    if(string-length($dd)=1) then
     			let $date_req:= concat('0', $dd)
     			let $result:= concat($year, $mon, $date_req)
     			return $result
     		    else 
     			let $date_req := $dd
     			let $result:= concat($year, $mon, $date_req)
         			return $result
  		else if($month= 'Sep')  then
  			let $mon:='09'
  			let $month_and_dd:= substring-before($original_date, ',')
  			let $dd:= substring-after($month_and_dd, ' ')
  			let $year_with_space:= substring-after($original_date, ',')
     		let $year:= replace($year_with_space, ' ', '')
  			return 
  			    if(string-length($dd)=1) then
     			let $date_req:= concat('0', $dd)
     			let $result:= concat($year, $mon, $date_req)
     			return $result
     		    else 
     			let $date_req := $dd
     			let $result:= concat($year, $mon, $date_req)
         			return $result
  		else if($month= 'Oct')  then
  			let $mon:='10'
  			let $month_and_dd:= substring-before($original_date, ',')
  			let $dd:= substring-after($month_and_dd, ' ')
  			let $year_with_space:= substring-after($original_date, ',')
     		let $year:= replace($year_with_space, ' ', '')
  			return 
  			    if(string-length($dd)=1) then
     			let $date_req:= concat('0', $dd)
     			let $result:= concat($year, $mon, $date_req)
     			return $result
     		    else 
     			let $date_req := $dd
     			let $result:= concat($year, $mon, $date_req)
         			return $result
  		else if($month= 'Nov')  then
  			let $mon:='11'
  			let $month_and_dd:= substring-before($original_date, ',')
  			let $dd:= substring-after($month_and_dd, ' ')
  			let $year_with_space:= substring-after($original_date, ',')
     		let $year:= replace($year_with_space, ' ', '')
  			return 
  			    if(string-length($dd)=1) then
     			let $date_req:= concat('0', $dd)
     			let $result:= concat($year, $mon, $date_req)
     			return $result
     		    else 
     			let $date_req := $dd
     			let $result:= concat($year, $mon, $date_req)
         			return $result
  		else if($month= 'Dec')  then
  			let $mon:='12'
  			let $month_and_dd:= substring-before($original_date, ',')
  			let $dd:= substring-after($month_and_dd, ' ')
  			let $year_with_space:= substring-after($original_date, ',')
     		let $year:= replace($year_with_space, ' ', '')
  			return 
  			    if(string-length($dd)=1) then
     			let $date_req:= concat('0', $dd)
     			let $result:= concat($year, $mon, $date_req)
     			return $result
     		    else 
     			let $date_req := $dd
     			let $result:= concat($year, $mon, $date_req)
         			return $result
           	else    let $result:= 'Error'
           	        return $result 

} ;


(:~
 : ------------------------------------------
 : The Anya Crawler XQuery Function Library
 : ------------------------------------------

 : Copyright (C) 2012 Arvind I K Chari

  

 : For more information on this XQuery library, contact arvind@anyaservices.com.

 : @version 1.1
 : @see     http://www.anyaservices.com
 :) 
module namespace  anyacrawler = "http://www.anyaservices.com" ;
 
(:~
 : Resolves first name, middle name, and last name from combined String
 :
 : @author  Arvind I K Chari, Anya Services 
 : @version 1.0 
 : @see     http://www.anyaservices.com/
 : @param   $wholename the name in this format FIRST_NAME MIDDLE_NAME LAST_NAME
 : @param   $delimiter the delimiter with which to separate the first, middle and last names
 :) 
 import module namespace  functx = "http://www.functx.com" at "http://546182fdd5275b6ead42-df5c28cde33ae816a8b8635168ae3631.r97.cf1.rackcdn.com/functx-1.0.xq";
 
declare function anyacrawler:resolvename 
  (  $wholename as xs:string ,
      $delimiter as xs:string 	)  as xs:string  {
       
       
       let $first_name:= substring-before($wholename, ' ')
       let $remaining_name:= substring-after($wholename, ' ')
       return
       	 if( contains($remaining_name, ' '))
         then let $last_name:= functx:substring-after-last($remaining_name, ' ')
	        let $middle_name:= functx:substring-before-last($remaining_name, ' ')
                let $result:= concat($first_name, $delimiter, $middle_name, $delimiter, $last_name)
                return $result
       	 else let $last_name:= $remaining_name
       	 	let $middle_name:= '' 
        	let $result:= concat($first_name, $delimiter, $middle_name, $delimiter, $last_name)
        	return $result
 };
 
(:~
 : Gets date in format yyyymmdd from format MMM dd,yyyy
 :
 : @author  Arvind I K Chari, Anya Services 
 : @version 1.1 
 : @see     http://www.anyaservices.com/
 : @param   $original_date Date in this format "Sep 12, 1997" (excluding quotes)
 : @result   date in this format-- "19970912" (excluding quotes)
 :) 
 declare function anyacrawler:dateconverter1($orig_date as xs:string) as xs:string {
      let $original_date:= $orig_date 
      let $month:= substring($original_date, 1,3)
      return 
      		if($original_date='')
	       	then    let $result:= ''
			return $result 
          	else	if(string-length($original_date)=4) then
         		let $result:= concat($original_date, '0000')
			return $result 
          	else 	if($month= 'Jan') then
      			let $mon:='01'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Feb') then
      			let $mon:='02'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Mar')  then
      			let $mon:='03'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Apr')  then
      			let $mon:='04'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'May')  then
      			let $mon:='05'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
     			
      		else if($month= 'Jun')  then
      			let $mon:='06'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Jul')  then
      			let $mon:='07'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Aug')  then
      			let $mon:='08'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Sep')  then
      			let $mon:='09'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Oct')  then
      			let $mon:='10'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Nov')  then
      			let $mon:='11'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
      		else if($month= 'Dec')  then
      			let $mon:='12'
      			let $month_and_dd:= substring-before($original_date, ',')
      			let $dd:= substring-after($month_and_dd, ' ')
      			let $year_with_space:= substring-after($original_date, ',')
	     		let $year:= replace($year_with_space, ' ', '')
      			return 
      			    if(string-length($dd)=1) then
         			let $date_req:= concat('0', $dd)
         			let $result:= concat($year, $mon, $date_req)
         			return $result
         		    else 
         			let $date_req := $dd
	     			let $result:= concat($year, $mon, $date_req)
             			return $result
               	else    let $result:= 'Error'
               	        return $result 
} ;

And an error for above file is also given below--

XQST0034: XQuery static error in #... return $result } ;#: Duplicate definition of function dateconverter1 (see line 56 in http://cf1.rackcdn.com/anyacrawler-1.1.xq)

What am I doing wrong here? How do I correct this error?

Yours sincerely, Arvind.

RE: Getting Duplicate Definition of Function Error when processing XQuery code with Saxon 8 in Java - Added by Michael Kay almost 11 years ago

It's difficult for me to see exactly what you are doing because of formatting issues. Your "first XQuery file" appears to declare a function anyacrawler:resolvename without declaring the prefix anyacrawler.

Please see if you can reproduce this using local files (without requiring HTTP requests) and then put together a repro in a ZIP file, with all required files so that we can run it here and reproduce the error. You can attach the ZIP file if you post it as a "new issue" in the support tracker.

RE: Getting Duplicate Definition of Function Error when processing XQuery code with Saxon 8 in Java - Added by Arvind IK Chari almost 11 years ago

Hi

Can you recommend a Editor/ Validator that basically just validates each XQuery file separately and points out the error? Something like an IDE/Editor for XQuery, which specifically validates against Saxon? And preferably something that is free/opensource (as I cannot afford to buy one now)?

That way I can check/validate the error easily?

Thanks, YOurs sincerely, Arvind.

RE: Getting Duplicate Definition of Function Error when processing XQuery code with Saxon 8 in Java - Added by Michael Kay almost 11 years ago

oXygen has support for Saxon XQuery. It's not open source; these tools rarely are.

    (1-5/5)

    Please register to reply