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?
ethar1Asked:
Who is Participating?
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.

Geert BormansInformation 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
1
ethar1Author Commented:
I am using
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

Open in new window

and cant change it.
0
Geert BormansInformation 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
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Geert BormansInformation 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
0

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
0
Geert BormansInformation 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
0
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

0
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


Thefile.xml:
<?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']">
			<File>
				<xsl:attribute name="name">
					<xsl:value-of select="@Name"/>.txt
				</xsl:attribute><xsl:attribute name="PersonName">
					<xsl:value-of select="@Name"/>
				</xsl:attribute>
				<xsl:for-each select="Members">					
					<xsl:apply-templates select="."/>
				</xsl:for-each>
				 
			</File>
		</xsl:for-each>
	</xsl:template>	
</xsl:stylesheet>

Open in new window

0
Geert BormansInformation 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
0
ethar1Author Commented:
ok, what about the example I give?
why its not working?
0
Geert BormansInformation ArchitectCommented:
not sure, that is why I gave you two steps to try
 "first" and "then"
Not set up to do debugging for you
0
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
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.