The XML for the media item is only available through the library extension, so that's why you need to use the copy-of instruction to actually get it back from a template call.
If you were to return the finished <img> (XML) tag from the template, you could just build it as a literal result, e.g.:
Please note I've changed 'false' to false() - a common pitfall with XSLT :-)
Also note that you could do more checking for missing values etc. if you want to bulletproof it - Lee Kelleher has a blogpost on this, that you should check out.
What is the best way to return XML from template
I created template that return teaserImage XML and is protected from empty numbers:
Here I used copy-of function. And I think that using it is not the best way.
Can I return full XML without copy it?
For example, I can set variable without copy XML, but it is not protected:
What is the best way to return XML from my template?
Hi AlexR,
I just posted an answer to your other post about this.
/Chriztian
Hi again,
Sorry, totally misunderstood your question I think.
If you need the media item XML, you need to use the copy-of instruction - that's how you do it.
/Chriztian
Thank you for answer. I asked because I just started to use XSLT.
If using copy-of is the only way to return XML I will use it.
Just to clarify:
The XML for the media item is only available through the library extension, so that's why you need to use the copy-of instruction to actually get it back from a template call.
If you were to return the finished <img> (XML) tag from the template, you could just build it as a literal result, e.g.:
Please note I've changed 'false' to false() - a common pitfall with XSLT :-)
Also note that you could do more checking for missing values etc. if you want to bulletproof it - Lee Kelleher has a blogpost on this, that you should check out.
/Chriztian
Chriztian, thank you for your note about false().
I returned XML for media because I want to work with image attributes in main template and so on.
I am creating one XSLT file with useful templates. I will include it into every usual XSLT files and I will use templates from included XSLT file.
I don't want write same functions in many templates.
So I need to know how to return node-sets from templates.
is working on a reply...