I would strongly advise against using this mixture of Xalan and Saxon code. It looks as if the Xalan command line processor is invoking the transformation entirely using JAXP interfaces, and can therefore invoke Saxon as an alternative to invoking Xalan if you set the environment up in the right way. But that's entirely an accident of the Xalan implementation and you're not achieving anything useful by doing this. You are running the Saxon transformation engine, and you should invoke it via Saxon interfaces.
It is not possible to use the Saxon extension functions when using the Xalan processor. Xalan, for example, does not maintain line numbers in its representation of the source document, so there is no way that the Saxon line-number() function could obtain the information it needs.
I don't know what the status is on running Saxon with Cocoon. I know they were doing the work at one stage, but I don't know if it ever got finished. Cocoon was making fairly extensive use of internal Xalan interfaces so it wasn't a trivial exercise.
Michael Kay
-----Original Message-----
From: Anna Afonchenko [mailto:anna@ubaccess.com]
Sent: 16 December 2002 09:48
To: michael.h.kay@ntlworld.com; saxon-help@lists.sourceforge.net
Subject: Re: [saxon] saxon:line-number() question

No, I am running Xalan using saxon extensions, and that works.
java -cp .;saxon.jar org.apache.xalan.xslt.Process -in input.xml -xsl styesheet.xsl -out output.xml
The output of system-property('xsl:vendor') is SAXON 6.5.2 from Michael Kay
Does this mean that xalan isn't even processing the stylesheet, but saxon is.  If so, there seems to be little point in using Process.  However, we want to use the xalan processor and take advantage of saxon extensions at the same time, especially because we also transform stylesheets from Cocoon and xalan is the default Processor of Cocoon.
It seems by what you are saying that if we do run the stylesheet from Cocoon, we will not be able to use the line numbering function, or even all the saxon extensions?
Thanks for your reply
----- Original Message -----
From: Michael Kay
To: 'Anna Afonchenko' ; saxon-help@lists.sourceforge.net
Sent: Monday, December 16, 2002 11:33 AM
Subject: RE: [saxon] saxon:line-number() question

Are you really saying you can run Saxon by invoking the Xalan command line with saxon.jar on the classpath? If so, I am very surprised. Are you sure this is actually running Saxon and not Xalan. What is the output of system-property('xsl:vendor')?
You can switch on Saxon line numbering for the source document by using the -l (letter ell) option on the command line, or by setting the LINE_NUMBERING attribute in the TransformerFactory.
TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute(FeatureKeys.LINE_NUMBERING, new Boolean(true));
See http://saxon.sourceforge.net/saxon7.3.1/using-xsl.html#Embedding for other attributes you can set. (This is for version 7.3.1. For 6.5.2 you will need to trawl through the JavaDoc to find the equivalent information).
Michael Kay
-----Original Message-----
From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Anna Afonchenko
Sent: 15 December 2002 10:00
To: saxon-help@lists.sourceforge.net
Subject: [saxon] saxon:line-number() question

Hi all.
I hope this is the right list to post this question.
I want to write in my xsl stylesheet that when it
matches some node to output some stuff, that the xsl
will also print the line number that this node appears in
the input file. I found the saxon function line-number(),
that seems to be what I need, but when I use it,
I get -1 as a result for any node.
It is mention on the saxon page that I may need to add -l option
on command line when running to enable line numbers, but my problem
that I don't really run my stylesheet using saxon, but using java with
saxon.jar instead to enable use of saxon functions along with some java extensions,
e.g. my command line looks like this:
java -cp .;saxon.jar org.apache.xalan.xslt.Process -in input.xml -xsl
styesheet.xsl -out output.xml

instead of running through saxon directly:
c:\saxon\saxon -o output.xml input.xml stylesheet.xsl

How can I define saxon to return valid line numbers?
Or maybe there is some other function that I can use?

Thank you very much for help.