The topic of creating XSLT function – and particularly, that of creating functions that embeds codes from other websites - cannot be limited to the guidelines in the previous chapters. However, the above guidelines give you a good start with XSLT functions.
You can of course do many other things in the area outlined above. In the following few short sections, you can learn what you can do in addition to what you have just learned.
Integrating with datatypes
In this case, we made functions that provide editors with a way to freely integrate video on pages wherever they like. You can also go for a more structured approach. For example, if you have a datatype called “News” and can often find a video to go with that you can make the videocode a field of the datatype. From there it actually is quite similar to what we have done in this guide, but now we specify in the function rendering the datatype that we also put in the code we have done above.
(XSLT Functions rendering datatypes is described in another document where the XML part also comes in.)
Possible enhancements: full URL, full embed code
Our functions have a little downside; they still require the editors to do some additional things, picking the right code from the URL or embed code.
It would be even better to allow pasting of a full URL, or even better the full embed code (which also holds the width and height), in which case the input parameter “videocode” could hold the full URL or embed code and the XSLT would retrieve the right values from out of there. But that requires some advanced parsing in the XHTML.
And even more?
There are many more online services that you can embed in a similar manner: online photos, online presentations, Google maps etc.
Have fun and let me know what you have come up with!
Oh, and of course, you can turn a function into an add-on so you don’t have to manually recreate it each time for different customers. But that story is part of another document.