Unexpected path behaviour using "document()"

Hi all,

I’m using XSLT to merge two XML files. I specify the external XML file containing data with a “document” function:

<xsl:variable name=“instances” select=“document(‘Instances-Data.xml’)”/>

This document has the following structure:


12
10




If I want to retrieve the value of “hasOleicAcid”, I would write this:

<xsl:value-of test=’$instances/Instances/Anchovies/hasOleicAcid’>

But it doesn’t work. Instead, I have to write:

<xsl:if test=’$instances//[name(.)=“Anchovies”]/[name(.)=“hasOleicAcid”]’>

Does anybody know why? Am I forced to perform a square brackets check every time I use an external XML file?

Thank you very much

I tried cutting and pasting your xsl:value-of element into a test stylesheet. When I tried running it with Saxon, it pointed out that the correct attribute for xsl:value-of is “select”, not “test”, and that the element needed a closing tag. Once I fixed those problems, it worked just fine.

If you just made a mistake when you transcribed the element into your post, and these errors did not exist in your original stylesheet, then you might have a bug in your XSLT processor.

Yes, I made a mistake when writing the post. I meant <xsl:value-of select… /> in both cases.

Anyway maybe it’s a problem with my XSLT processor. I’m currently using msxsl 3.0 I’ll try using Saxon