2

I am working on templating using XSLT Mediator and wrote custom function to get the ItemXML of Component because leagcy document function not provide category keyword info in generated xml.

   public XPathNodeIterator GetItemxml(string tcmID)
    {
        XPathNodeIterator Xpathnav = null;
        XPathNavigator navigator = null;
        if (!String.IsNullOrEmpty(tcmID.Trim()) && TcmUri.IsValid(tcmID.Trim()))
        {

            IdentifiableObject itemObject = (IdentifiableObject)this.Engine.GetObject(tcmID.Trim());
            //Get Additional Keyword Information
            itemObject.Load(LoadFlags.KeywordXlinks);

            if (itemObject != null)
            {
                navigator = itemObject.ToXml().CreateNavigator();
                Xpathnav = navigator.Select("/");
            }
        }
        else
        {
            XmlDocument doc = new XmlDocument();
            navigator = doc.CreateNavigator();
            Xpathnav = navigator.Select("*");
        }
        return Xpathnav;
    }

I found that performace of my custom function is not good as default document function if I called custom function multiple time in one template.

Any idea why and how document function create component xml ?

2 Answers 2

4

The document() function will almost certainly cache the result, so if you call it twice, supplying the same URI, then the document will not be re-read and re-parsed on the second and subsequent occasions. Your custom function is not maintaining a similar cache.

1

I am guessing that it is because you are using this line

itemObject.Load(LoadFlags.KeywordXlinks);

This is forcing the system do load additional data which is not included in the default XML. I am not 100% sure, but I imagine when you call this flag, instead of loading just the Component object, it loads all of the Keyword objects in order to get the xlink:title attributes etc.

I found the same thing when I added keyword loading to the XSLT Mediator for this post: http://www.tridiondeveloper.com/the-community-xslt-mediator-vs-sdl-tridion-2013-xslt-template-building-blocks

I am not sure you will be able to do much about it though. If you want to retrieve more data, it will normally take longer to retrieve.

2
  • Thanks Chris , you are right ,to get the keyword xlink:href i am using custom code. due to this my custom function taking longer time as you said. Thanks for your valuable comment............. Commented Mar 30, 2015 at 15:51
  • 1
    It's a valid guess, but not true in this particular case. The additional XLink attributes are always loaded, but stripped off in case LoadFlags.KeywordXlinks is not specified. You could try to enable CM tracing in Tridion.ContentManager.config to get a better picture of what's happening under the hood. Commented Mar 30, 2015 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.