in C# I want to select all nodes where the start and end date values cover the selected day.
E.g. if the selected day is 2 Jan 2012 and a node has start / end dates of 1 Jan 2012 / 4 Jan 2012 then it will be selected. I tried the XSLT below which worked fine as XSLT but I cannot use it within my User Control:
<xsl:copy-of select="$currentPage/ancestor-or-self::Calendar/CalendarAlteration
[@isDoc and umbraco.library:DateGreaterThanOrEqual('2012-01-02',
substring(fromDate, 1, 10)) and
umbraco.library:DateGreaterThanOrEqual(substring(toDate, 1, 10),
'2012-01-02')]"/>
The date '2012-01-02' is the selected day. This gives an error "Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function."
So, how can I do the equivalent of the XSLT in C# ?
Select nodes within date range
in C# I want to select all nodes where the start and end date values cover the selected day.
E.g. if the selected day is 2 Jan 2012 and a node has start / end dates of 1 Jan 2012 / 4 Jan 2012 then it will be selected. I tried the XSLT below which worked fine as XSLT but I cannot use it within my User Control:
<xsl:copy-of select="$currentPage/ancestor-or-self::Calendar/CalendarAlteration [@isDoc and umbraco.library:DateGreaterThanOrEqual('2012-01-02', substring(fromDate, 1, 10)) and umbraco.library:DateGreaterThanOrEqual(substring(toDate, 1, 10), '2012-01-02')]"/>
The date '2012-01-02' is the selected day. This gives an error "Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function."
So, how can I do the equivalent of the XSLT in C# ?
Hi Gordon,
Unfortuately you can't use custom extensions (e.g. "umbraco.library") in the XPath when calling something like GetXmlNodeByXPath.
Not to constantly push uComponents, but if you are already using it... then you could take advantage of some uQuery methods?
e.g.
(Written off the top of my head - completely untested!)
Cheers, Lee.
Yes, I remembered that you can't use custom extensions the first time I tried the page / code!!
I am using uComponents so I will give your solution a go...
Thanks Lee - with a few adjustments, your suggestion worked :-) Thank you very much.
is working on a reply...