xml xsl Unknown method. -->position()<-- != last()

Dear all
I am trying to find the index number of the node within a parent and insert code
if it isn't the LAST node.
<xsl:if test="position() != last()">

When I run the
code, I get this error:

Error Unknown method. -->position()<-- at MSXML2.IXMLDOMDocument2.transformNode(IXMLDOMNode stylesheet) at ...

the code in c#:
MSXML2.XSLTemplate DOMDocument30= new MSXML2.DOMDocument30();

Open in new window

Any ideas?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gertone (Geert Bormans)Information ArchitectCommented:
please show us the full XSLT

note that
<xsl:if test="not(position() = last())">
is a better test

but I fear you are having the wrong namespace in your XSLT
ethar1Author Commented:
I am using
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

Open in new window

and cant change it.
Gertone (Geert Bormans)Information ArchitectCommented:
That is what I suspected.

I respect that you can't change that, but....

you are about the only person I know that is still using the Working Draft XSL,
(support has been dropped over 10 years ago)
so please, in future XSLT questions, start by mentioning that context.
There are very few that have the historical background to help you with this
and I think that books or tutorials have long vanished from the internet.

position() definitely is simply not supported and I don't remember the alternative by heart

I will try to dig up some old course material I have left, maybe I can find an answer...
if not, start thinking about migration... because using the old WD-XSL will really be hard to maintain
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Gertone (Geert Bormans)Information ArchitectCommented:
Having said that, you could try

<xsl:if test="last-of-any()">

if you are looking for the last element of a series of elements of the same name

<xsl:if test="last-of-type()">

would be more solid

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ethar1Author Commented:
ok, thanks,
I found this
<xsl:if test="context()[not(end())]"></xsl:if>

Open in new window

do you know any practical way to do transformation , its a huge xsl file
Gertone (Geert Bormans)Information ArchitectCommented:
yes, you told me it is huge.

The best "first step" would be an XSLT that does the bulk of the work.
The example you had earlier does some of the work, but it is a far from perfect project.
I am not aware of other projects that do the same

Personally I would develop XSLTs that do seperate steps
- first pull out all the javascript function, evaluate them and redo them when necessary to put in  a script element, others that are now ms xtension functions or existing xslt1 functions
- transform the clean WD-XSL to XSLT1
- put the functions back in

But this requires some knowledge of both WD-XSL and XSLT1
ethar1Author Commented:
the current xsl is very simple not more then :
<xsl:for-each select="xxxx" order-by="@yyyy">
xsl:value-of select="@Name"/> 

Open in new window

ethar1Author Commented:
Here is very basic & simple xsl witch failed to converted by suggest MS file (xsl-xslt-converter.xslt)

c# code:
			XsltSettings mySettings = new XsltSettings();
			mySettings.EnableScript = true;
			XslCompiledTransform xslt = new XslCompiledTransform();
			xslt.Load(Server.MapPath(@"xsl-xslt-converter.xslt"), mySettings , null); //
			xslt.Transform(Server.MapPath(@"Thefile.xsl"), Server.MapPath(@"Thefile.xslt"));

Open in new window

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
		<xsl:template match="/">
		<xsl:for-each select="Community/Person[@GInclude='true']">
				<xsl:attribute name="name">
					<xsl:value-of select="@Name"/>.txt
				</xsl:attribute><xsl:attribute name="PersonName">
					<xsl:value-of select="@Name"/>
				<xsl:for-each select="Members">					
					<xsl:apply-templates select="."/>

Open in new window

Gertone (Geert Bormans)Information ArchitectCommented:
first make sure that the mini WD-xsl you made is valid WD-XSL
make a test run a view the results
(I am not certain all constructs are valid, but have to admit that my WD-xsl is rusty)

then make sure you find a way to catch the error messages
(running from stylus studio, xml spy or command line makes more sense for debugging than running from code, I remember having told you that before)

If this were my project, I would certainly make an XSLT2 of the xsl-xslt-converter.xslt which would lead to cleaner and robuster code, and would do proper debugging in Oxygen or stylus studio
You need to know that the converter that you are using is a one person project, fit for his personal requirements, and there is quiet a bit of finetuning required to use it in a general context

I think you need to make some hard decissions at some point = invest in a proper migration of the 10k lines. Maybe you need to start thinking about redoing that project from the specs. In the long run that will be the cheapest option. You have been fighting with this code for over a year now as far as I remember. You have my private email address. You could send me an NDA, I can sign that and after you send me the WD-XSL, some source and some results documents. So can propose a best approach to migration
ethar1Author Commented:
ok, what about the example I give?
why its not working?
Gertone (Geert Bormans)Information ArchitectCommented:
not sure, that is why I gave you two steps to try
 "first" and "then"
Not set up to do debugging for you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.