Are you using an implementation of XSLT which supports functions in this namespace? Or to put it another way, does xs:date work with other inputs but just not with this input, or does it never work?
So what leads you to believe that your XSLT implementation supports functions in this namespace at all?
I'm not saying it doesn't; but since that namespace was designed long after XSLT was, it is quite possible that your transformer doesn't support it. I'm just asking what documentation you read which tells you that it does or doesn't.
I am naive user of xslt and haven't read any document to confirm that the transformer supports this, I just referred the w3schools website for getting the year of a value and using it.
Frankly I am blank on whether it is supported or not. I have xmlapis.jar, xalan.jar and the xerces.jar in my classpath and just running the transformer on the xsls edited with the year-from-dateTime function.
That's what I suspected. The w3schools tutorial is shamefully missing information about which functions work with XSLT 1.0 and which functions work with XSLT 2.0. Don't waste too much time using that as your primary reference, get yourself a proper book.
However, in my specific case, I wouldnt be knowing the kind of format of the date from which I need to extract the year and so on.
So irrespective of the format I need to extract the year, month, etc components and thus I believe I have to go with year-from-dateTime sort of options.
It's possible to call Java code from an XSLT. But you won't find that covered in the web tutorials (along with a lot of other XSLT basics). Sorry, I'm afraid you're going to have to get a proper reference for that too.
Or alternatively you could use something which supports XSLT 2.0, as your Java code would have the same problem of not knowing the format of the date. (I'm not sure how you expect the xs:date function to deal with that problem but let's leave that aside for now.)