Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • webmonger 130 posts 285 karma points
    Jan 13, 2011 @ 15:44
    webmonger
    0

    Parse XML through XSLT Engine in /base

    Hi

    I'm looking to parse some XML through the Umbraco XSLT engine from a .net class thats accessed via the /base rest interface.

    So far i've tried using

    umbraco.library.RenderMacroContent(@"<umbraco:Macro Alias='macroalias' runat='server'></umbraco:Macro>",id)

    but this just re-renders the <umbraco:macro~> code

    Is there an easy way to access the XSLT Macro Engine via the API?

    Cheers

    Jon

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 13, 2011 @ 15:56
    Douglas Robar
    1

    Looks like you need some escaping, and the old v3 syntax. 

    Check http://en.wikibooks.org/wiki/Umbraco/Reference/umbraco.library/RenderMacroContent for details.

    cheers,
    doug.

  • webmonger 130 posts 285 karma points
    Jan 13, 2011 @ 16:04
    webmonger
    0

    Hi Doug

    Thanks for the speedy reply. Just tested the old v3 code and it's still just rendering the content I placed to be converted. e.g

    umbraco.library.RenderMacroContent("&lt;?UMBRACO_MACRO macroAlias=&quot;macroalias&quot; &gt;&lt;/?UMBRACO_MACRO&gt;", id);

    This just renders "<?UMBRACO_MACRO macroAlias="macroalias" ></?UMBRACO_MACRO>

    Curious!

    Jon

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jan 13, 2011 @ 16:14
    Matt Brailsford
    1

    Hey Jon.

    Have you tried UN escaping the special characters, as I have the feeling they only recommend encoding them as documentation assumes you are calling the method from XSLT, which would require them to be escaped, but you are calling it from code.

    umbraco.library.RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"macroalias\" ></?UMBRACO_MACRO>", id);

    Matt

  • webmonger 130 posts 285 karma points
    Jan 13, 2011 @ 16:26
    webmonger
    0

    Spot on Matt. That worked perfectly. Now i just need to work out how to get currentPage working ;)

    Cheers

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jan 13, 2011 @ 16:31
    Douglas Robar
    0

    Ah yes, of course. Thanks, Matt. What a team! :)

    cheers,
    doug.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 13, 2011 @ 16:38
    Jan Skovgaard
    1

    Just for information I took the liberty to copy the content from the old reference into the new reference here on our. Then information can now be found at http://our.umbraco.org/wiki/reference/umbracolibrary/rendermacrocontent also. (Asuming that some day the old umbraco wiki site will no longer be around)...

    /Jan

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jan 13, 2011 @ 16:40
    Matt Brailsford
    0

    @Jon no problem

    @Doug Absolutley! #h5wr

  • webmonger 130 posts 285 karma points
    Jan 13, 2011 @ 16:59
    webmonger
    0

    @Jan - Good idea. I had seen that wikibooks post but ignored it as it was very old. Having it in the wiki validates its uses again for me. Cheers

Please Sign in or register to post replies

Write your reply to:

Draft