Hi, I don't know if is it possible but I need something similar: pass to a variable its select value through a function of my custom library that returns the query (really complex based on many macro parameters) to execute and get every node.
Could you give us a little more details on what seems to be your problem? Are you having trouble iterating through some XML returned by your custom extension or?
my problem is that i have many macro parameters that change the query used to display nodes through a for-each loop.
Public Shared Function selectStatement(xxx as string, yyy as string, zzz as string) As String 'combine all conditions passed to append to the final query '... Return "umbraco.library:GetXmlNodeById($nodeId)/News [umbraco.library:DateGreaterThanOrEqual(archiveDate, $currentDate)][@isDoc and string(umbracoNaviHide) != '1'][string(highlighted) = '1']" End Function
Error parsing XSLT file: \xslt\NewsList.xsl
This is just an example but i need to verify all variables passed to selecStatement function and build the final query to return to the $nodes variable.
There are a lot of combinations and let do the job to a .net function i think is more easy to do (instead of insert multiple choose or if)
Yes, this is the way i'm looking for. But I need your help again.
Public Shared Function selectStatement(ByVal nodeId As String) As XPathNodeIterator 'just for test Return umbraco.library.GetXmlNodeById(nodeId) End Function
And again, How "translate" umbraco.library:GetXmlNodeById($nodeId)/News
[umbraco.library:DateGreaterThanOrEqual(archiveDate,
$currentDate)][@isDoc and string(umbracoNaviHide) !=
'1'][string(highlighted) = '1'] for selectStatement function?
ok, test done, $nodes contains all nodes given by GetXmlNodeById(nodeId) with properties and all. I tried to change the select attribute of for-each loop in this way <xsl:for-each select="msxml:node-set($nodes)"> but nothing happen...
Sjors, really really thanks!!! Now I see the results.
Now the last question, if you are so patient to resolve it:
I'm trying with no success:
Dim xpn As XPathNodeIterator =
umbraco.library.GetXmlNodeById(nodeId).Current.CreateNavigator().Select("//News [umbraco.library:DateGreaterThanOrEqual(archiveDate, $currentDate)][@isDoc and string(umbracoNaviHide) != '1'][string(highlighted) = '1']")
seems that [umbraco.library:DateGreaterThanOrEqual(archiveDate, $currentDate)] is not possible because if i remove it from expression all works fine.. how can I insert this condition too?
and archiveDate >= '<xsl:value-of select="$currentDate"/>'
</xsl:variable>
now, how verify or use umbraco.library.DateGreaterThanOrEqual(archiveDate, $currentDate) ? the code above doesn't give me errors but nodes are not displayed, while DateGreaterThanOrEqual is not possible to use (well, I'm not able to use it inside the variable $searchString)...
Select statement through function
Hi,
I don't know if is it possible but I need something similar: pass to a variable its select value through a function of my custom library that returns the query (really complex based on many macro parameters) to execute and get every node.
<xsl:variable name="nodes" select="custom.library:selectStatement()" />
<xsl:for-each select="$nodes">
...
</xsl:for-each>
Really thanks
Hi
Could you give us a little more details on what seems to be your problem? Are you having trouble iterating through some XML returned by your custom extension or?
And what does the $nodes contain?
/Kim A
Hi Kim,
my problem is that i have many macro parameters that change the query used to display nodes through a for-each loop.
Public Shared Function selectStatement(xxx as string, yyy as string, zzz as string) As String
'combine all conditions passed to append to the final query
'...
Return "umbraco.library:GetXmlNodeById($nodeId)/News [umbraco.library:DateGreaterThanOrEqual(archiveDate, $currentDate)][@isDoc and string(umbracoNaviHide) != '1'][string(highlighted) = '1']"
End Function
Error parsing XSLT file: \xslt\NewsList.xsl
This is just an example but i need to verify all variables passed to selecStatement function and build the final query to return to the $nodes variable.
There are a lot of combinations and let do the job to a .net function i think is more easy to do (instead of insert multiple choose or if)
Many thanks for your help
Not sure or this is what you want, but i use something like this:
public static XPathNodeIterator GetMostViewed(string parentId)
{
DataSet ds = getDataSetFromSql(ConfigurationSettings.AppSettings["BussinessConnection"], "GetMostViewed " + parentId, "doc");
XmlDataDocument dataDoc = new XmlDataDocument(ds);
return dataDoc.CreateNavigator().Select(".");
}
In XSLT:
<xsl:variable name="items" select="MyHelperLib:GetMostViewed($parentid)"/>
Yes, this is the way i'm looking for. But I need your help again.
Public Shared Function selectStatement(ByVal nodeId As String) As XPathNodeIterator
'just for test
Return umbraco.library.GetXmlNodeById(nodeId)
End Function
<xsl:variable name="nodeId" select="/macro/contentNode" />
<xsl:variable name="nodes" select="custom.library:selectStatement($nodeId)" />
<xsl:for-each select="$nodes">
...
</xsl:for-each>
But nothing happend; no errors, no results.
And again, How "translate" umbraco.library:GetXmlNodeById($nodeId)/News [umbraco.library:DateGreaterThanOrEqual(archiveDate, $currentDate)][@isDoc and string(umbracoNaviHide) != '1'][string(highlighted) = '1'] for selectStatement function?
Really really thanks to all!
A good test is to debug it with: <xsl-copy-of select"$nodes"/> and see what it contains.
ok, test done, $nodes contains all nodes given by GetXmlNodeById(nodeId) with properties and all.
I tried to change the select attribute of for-each loop in this way <xsl:for-each select="msxml:node-set($nodes)"> but nothing happen...
ok, now you have to find the element which you want to repeat, you will have to do something like this;
xsl:for-each select="$nodes/docs/doc">
Where docs is the toplevel node, and doc the nodes which are repeating.
Sjors, really really thanks!!! Now I see the results.
Now the last question, if you are so patient to resolve it:
I'm trying with no success:
Dim xpn As XPathNodeIterator =
umbraco.library.GetXmlNodeById(nodeId).Current.CreateNavigator().Select("//News [umbraco.library:DateGreaterThanOrEqual(archiveDate, $currentDate)][@isDoc and string(umbracoNaviHide) != '1'][string(highlighted) = '1']")
seems that [umbraco.library:DateGreaterThanOrEqual(archiveDate, $currentDate)] is not possible because if i remove it from expression all works fine.. how can I insert this condition too?
I found this article (thanks Lee):
http://www.blogfodder.co.uk/2009/12/22/building-a-dynamic-xpath-statement-in-xslt
and I totally changed my approch, now all works fine (better than before) but the problem related to the dates is the same:
<xsl:variable name="searchString">
@isDoc and string(umbracoNaviHide) != '1'
<xsl:if test="string($showOnlyHighlighted) = '1'">
and string(highlighted) = '1'
</xsl:if>
and archiveDate >= '<xsl:value-of select="$currentDate"/>'
</xsl:variable>
now, how verify or use umbraco.library.DateGreaterThanOrEqual(archiveDate, $currentDate) ? the code above doesn't give me errors but nodes are not displayed, while DateGreaterThanOrEqual is not possible to use (well, I'm not able to use it inside the variable $searchString)...
is working on a reply...