XSLT has some shortcomings compared to a lot of ordinary programming language features, for example variable and switch, are not implemented the way we are typically used to from other languages. It is not a programming language in a classical sense, rather an xml parsing tool.
You can develop what is known as XSLT extensions in c# and then call those from within your xslt. I have not done this myself, but others might be able to help you out :)
With searching, you can create a ordinary dll and dump it in the /bin folder of the Umbraco site. From there on, you can add a usercontrol that uses the features of the dll. Or at least thats what I would do to implement my own custom search.
I guess there are other ways to implement this as well.
By the way with regards to switch and XSLT I would recommend sticking with your if's - even though I agree its not pretty I think its the best solution within the limitations of xslt.
Who to use Switch Statement in Xslt
Hi
I use Xslt and use there 4 if statement . Now My Question is that who can i use Switch Statement instead of many if else.
Can any one Help me.
Thanks
Hussain
Hi Muhammad,
XSLT has some shortcomings compared to a lot of ordinary programming language features, for example variable and switch, are not implemented the way we are typically used to from other languages. It is not a programming language in a classical sense, rather an xml parsing tool.
I suggest that you look at "choose" at w3schools, that might be useful for you: http://www.w3schools.com/xsl/xsl_choose.asp
Hope that helps.
Brgds.
Anders
Hi Anders,
Thanks for Response. If i do Coding in C# for Switch Statement and i want to call this Function In XSlt. WHo Can I Do this.
The Second Thing is that i want to implement Searching from C# and use this Seaching Function in Umbraco. Who Can Do this.
Thanks
Hussain
You can develop what is known as XSLT extensions in c# and then call those from within your xslt.
I have not done this myself, but others might be able to help you out :)
With searching, you can create a ordinary dll and dump it in the /bin folder of the Umbraco site. From there on, you can add a usercontrol that uses the features of the dll. Or at least thats what I would do to implement my own custom search.
I guess there are other ways to implement this as well.
By the way with regards to switch and XSLT I would recommend sticking with your if's - even though I agree its not pretty I think its the best solution within the limitations of xslt.
Brgds. Anders
Muhammad I think an example would help:
Xslt with 4 if:
Xslt with one choose instead of if:
hth, Thomas
hth, Thomas,
Thanks for Resposne but this is like if else and if else and so on. This is not like Switch in C#. The switch use case in Switch.
Hussain
is working on a reply...