When access this method in my XSLT script I don't get any errors, but I don't get anything out either. What I'm trying to do is getting my XSLT extension to return a set of nodes that I can iterate.
Does this work?
Is there a different way to to it?
Thanks guys! Will do some more experimenting tomorrow!
Since Umbraco is such a versatile tool, it's sometimes hard to know the quickest and easiest way to access content outside the ordinary Umbraco content. Previously I've coded custom user controls, but I love the formatting and iterating abilities of XSLT and XSLT extensions written in .NET seems to be the perfect tool.
Are there more ways to work with external content in Umbraco?
For displaying external Data. I think XSLT Extensions are the best way. It gives you the power of .NET to retrieve data with the DAL you prefer. and markup the layout with the power of XSLT.
Currently I'm building a package for a client that can also maintain external data in Umbraco using a custom datatype and Umbraco Controls. So that's another way of working with external data.
[quote=rsoeteman]
Currently I'm building a package for a client that can also maintain external data in Umbraco using a custom datatype and Umbraco Controls. So that's another way of working with external data.
And you can always import data offcourse ;-) [/quote]
Wow, that sounds exciting!
I sometimes find myself in situations where I want the best of two worlds: the fantastic website platform of Umbraco AND the full freedom that a blank C#/ASP.NET project gives me.
For setting up complex database structures, Umbraco is not a good tool (relations, stored procedures etc). And still it would be great if I could set up such a structure that could live side by side with Umbraco and I could both display the content on the public pages and edit the content of this structure from inside Umbraco.
Thank's everyone!
I now have a working demo of a class that returns custom data as an XPathNodeIterator and I can continue working with it inside my XSLT in Umbraco.
The method looks like this:
[code]
public static XPathNodeIterator GetTestXML()
{
And the result on the page is:
[b]Brian - male
Elena - female
John - male[/b]
Works great!
Now I just have to figure out how to build an admin interface for a custom database that I want to place inside Umbraco. I'm thinking about using custom datatypes, but I'm not sure if it will work. For example I will be needing a complete form with drop-down menues that fetch their values from other tables and I will need to store data directly to an external database table. I will only use Umbraco for presentation of data - no storage in Umbraco.
I'm currently building a solution for a client that can do this Here is a picture from a few weeks back. I cannot go into to much details. But what I did was the following:
- Create a new data type
- Create a few extra controls for 1/n n/n data relations
- Create my own implementation of Idata and call the Webcontrol (Class that uses IDataEditor) directly. I did that because now i can get and set the Idata.Value propertyu from my own datasource in my case an sql database.
This works perfectly except for the TinyMCE editor control (still don't know why).
Again I cannot go into to much detail but hope this post gives you enough insight.
XSLT extension (C#) returning an XmlDocument?
Hi!
I'm experimenting with an XSLT extension coded as a class library in C#. I have written a method that returns an XmlDocument:
[code]
public static XmlDocument GetTestXML()
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement mother = xmlDoc.CreateElement("questions");
XmlElement question1 = xmlDoc.CreateElement("question");
question1.InnerText = "How long is a string?";
mother.AppendChild(question1);
XmlElement question2 = xmlDoc.CreateElement("question");
question2.InnerText = "Do you feel lucky?";
mother.AppendChild(question2);
return xmlDoc;
}
[/code]
When access this method in my XSLT script I don't get any errors, but I don't get anything out either. What I'm trying to do is getting my XSLT extension to return a set of nodes that I can iterate.
Does this work?
Is there a different way to to it?
Thanks in advance!
/Thomas
Hmm - perhaps my method should return an XPathNodeIterator instead?
Would that work better?
.NET XSLT is expecting an XPathNodeIterator.
Same if you are passing xml to an extension method.
Hi Thomas,
You should indeed return a NodePathIterator. The first three minutes of this video are free and shows you how to do that.
Regards,
Richard
Thanks guys! Will do some more experimenting tomorrow!
Since Umbraco is such a versatile tool, it's sometimes hard to know the quickest and easiest way to access content outside the ordinary Umbraco content. Previously I've coded custom user controls, but I love the formatting and iterating abilities of XSLT and XSLT extensions written in .NET seems to be the perfect tool.
Are there more ways to work with external content in Umbraco?
Hi Thomas,
For displaying external Data. I think XSLT Extensions are the best way. It gives you the power of .NET to retrieve data with the DAL you prefer. and markup the layout with the power of XSLT.
Currently I'm building a package for a client that can also maintain external data in Umbraco using a custom datatype and Umbraco Controls. So that's another way of working with external data.
And you can always import data offcourse ;-)
[quote=rsoeteman]
Currently I'm building a package for a client that can also maintain external data in Umbraco using a custom datatype and Umbraco Controls. So that's another way of working with external data.
And you can always import data offcourse ;-) [/quote]
Wow, that sounds exciting!
I sometimes find myself in situations where I want the best of two worlds: the fantastic website platform of Umbraco AND the full freedom that a blank C#/ASP.NET project gives me.
For setting up complex database structures, Umbraco is not a good tool (relations, stored procedures etc). And still it would be great if I could set up such a structure that could live side by side with Umbraco and I could both display the content on the public pages and edit the content of this structure from inside Umbraco.
I'd love it if you could document your work!
/Thomas K
You probably have all the info you need already, but here is another thread that discusses returning XML data from an XSLT extension:
http://forum.umbraco.org/yafpostst7905how-to-send-nodeset-to-xslt-extension-and-back.aspx
In the first post there is also a link to a code example.
Thank's everyone!
I now have a working demo of a class that returns custom data as an XPathNodeIterator and I can continue working with it inside my XSLT in Umbraco.
The method looks like this:
[code]
public static XPathNodeIterator GetTestXML()
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement elemMother = xmlDoc.CreateElement("Mom");
xmlDoc.AppendChild(elemMother);
XmlElement kidOne = xmlDoc.CreateElement("Kid");
kidOne.SetAttribute("gender", "male");
kidOne.SetAttribute("name", "Brian");
elemMother.AppendChild(kidOne);
XmlElement kidTwo = xmlDoc.CreateElement("Kid");
kidTwo.SetAttribute("gender", "female");
kidTwo.SetAttribute("name", "Elena");
elemMother.AppendChild(kidTwo);
XmlElement kidThree = xmlDoc.CreateElement("Kid");
kidThree.SetAttribute("gender", "male");
kidThree.SetAttribute("name", "John");
elemMother.AppendChild(kidThree);
XPathNodeIterator xNodeIt = xmlDoc.CreateNavigator().Select(".");
return xNodeIt;
}
[/code]
Here's how I use it in my XSLT:
[code]
]>
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
xmlns:ThomasCustomMethods="urn:ThomasCustomMethods"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets MusiktavlingMethods">
[/code]
And the result on the page is:
[b]Brian - male
Elena - female
John - male[/b]
Works great!
Now I just have to figure out how to build an admin interface for a custom database that I want to place inside Umbraco. I'm thinking about using custom datatypes, but I'm not sure if it will work. For example I will be needing a complete form with drop-down menues that fetch their values from other tables and I will need to store data directly to an external database table. I will only use Umbraco for presentation of data - no storage in Umbraco.
/Thomas K
Hi Thomas,
I'm currently building a solution for a client that can do this Here is a picture from a few weeks back. I cannot go into to much details. But what I did was the following:
- Create a new data type
- Create a few extra controls for 1/n n/n data relations
- Create my own implementation of Idata and call the Webcontrol (Class that uses IDataEditor) directly. I did that because now i can get and set the Idata.Value propertyu from my own datasource in my case an sql database.
This works perfectly except for the TinyMCE editor control (still don't know why).
Again I cannot go into to much detail but hope this post gives you enough insight.
Richard
Thanks Richard! It's very helpful to know that it is doable!
is working on a reply...