It sounds like something has gone wrong in your installation, as you should only have one root "Content" node. You'll then create one or more site roots under this node.
To get at the root node, you'll want to use $currentNode/ancestor-or-self::root, but as I say, if you've got 2 nodes, something isn't quite right.
It looks like you're accidentally supplying the wrong context (or none) to your XPath expression - if you're inside a for-each statement and you use the above expression, you're asking for ALL node elements with the parentID -1, if that's your scenario, you'll just need to supply $currentPage as context - like this:
So you're declaring some kind of datatype and you're using some XPATH to set the parent node ID, am I right? If that's the case you should be able to use $currentPage like you would in XSLT.
Get root of current content
Hi,
I have 2 contents.
I want to get root node ( parentID="-1" level="1" ) of content that I'm in it now.
If I write:
//ancestor::node[@parentID= -1]
I receive two roots with parentID="-1" .
How can I get only one root of current content?
Thanks
Hi Kukuwka,
It sounds like something has gone wrong in your installation, as you should only have one root "Content" node. You'll then create one or more site roots under this node.
To get at the root node, you'll want to use $currentNode/ancestor-or-self::root, but as I say, if you've got 2 nodes, something isn't quite right.
Matt
Hi kukuwka,
It looks like you're accidentally supplying the wrong context (or none) to your XPath expression - if you're inside a for-each statement and you use the above expression, you're asking for ALL node elements with the parentID -1, if that's your scenario, you'll just need to supply $currentPage as context - like this:
/Chriztian
I want to use it in Data Types and not in XSLT Files .
So "$currentPage" not fit here.
Thanks.
So you're declaring some kind of datatype and you're using some XPATH to set the parent node ID, am I right? If that's the case you should be able to use $currentPage like you would in XSLT.
In principle you can select the root of any xml file via
and if you don't have the currentPage variable you can select it via
Snippet
So you can select the root of the content nodes via
hth, Thomas
If I use:
string Xpath = "$currentPage/ancestor-or-self::node[@parentID = -1]"; iterator=library.GetXmlNodeByXPath(Xpath));
I get:
Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
How can I solve it?
kukuwka.
is working on a reply...