what does your test return if you just write in a value-of like this: <xsl:value-of select="$currentPage/ancestor-or-self::* [name()='DK']" /> - does it return true or false?
It returns all the content so i guess it's true :o)
And if i try following, like above, just not with the @nodeName, it gives me the Article content but i cant select the single content parts like /pageHeader, /@nodeName or /contentText.
There are some errors in the above snippet. whentest is not in one line but should be when test as in your first example. And value-ofselect should be value-of select.
However...what is it you're trying to achieve here?
The value-of instruction always returns a string, so you can't subsequently use XPath on that variable. If you need to conditionally select different nodes, use this pattern:
The important part is that you're using copy-of instead of value-of, and then you need to use the msxsl:node-set() extension to be able to use XPath on the variable afterwards.
But the solution to the problem at hand is much simpler - I always use a siteRoot variable right after the currentPage param:
Variable and choose, can't reach node propertys
Why cant i reach the propertys when i do like this:
But if i do like this it works fine:
I cant see what i'm missing? any clues?
Hi Mads
what does your test return if you just write in a value-of like this: <xsl:value-of select="$currentPage/ancestor-or-self::* [name()='DK']" /> - does it return true or false?
/Jan
Hej Jan
It returns all the content so i guess it's true :o)
And if i try following, like above, just not with the @nodeName, it gives me the Article content but i cant select the single content parts like /pageHeader, /@nodeName or /contentText.
BTW it gives me a Error parsing XSLT file
Hi Mads
There are some errors in the above snippet. whentest is not in one line but should be when test as in your first example. And value-ofselect should be value-of select.
However...what is it you're trying to achieve here?
/Jan
Hi Jan
Dont know why that happend :D
I have a structure look like this
Content
Site
-DK (DocType DK)
--FrontPage
--Media
---Article Archive
----Articles
-UK (DocType UK)
--FrontPage
--Media
---Article Archive
----Articles
I have a articles.xslt placed at
FrontPage
Article Archive
Articles
At the frontpage i would like dick down i the article archive at the current Language and reach the latest article.
So i try to do something like this
Hi Mads,
To answer the question about the variable:
The value-of instruction always returns a string, so you can't subsequently use XPath on that variable. If you need to conditionally select different nodes, use this pattern:
The important part is that you're using copy-of instead of value-of, and then you need to use the msxsl:node-set() extension to be able to use XPath on the variable afterwards.
But the solution to the problem at hand is much simpler - I always use a siteRoot variable right after the currentPage param:
(You may need to adjust the level to match your setup)
Then you can select all Article nodes below that, like this:
- and use that in your for-each - it reads a million times easier for anyone reading the code.
/Chriztian
ahh great idea about the siteRoot that save me for a lot of code :D
Btw i really like your http://pimpmyxslt.com/axesviz.aspx it really make sense to a none-web-shark :o)
is working on a reply...