Copied to clipboard

Flag this post as spam?

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


  • Duke Maximus 23 posts 20 karma points
    May 19, 2009 @ 03:05
    Duke Maximus
    0

    Accessing config settings in XSLT

    Hi everyone, is there a straight forward way of accessing the settings in a custom config file or will I have to create a .net assembly to return the values?

    Thanks in advance!

  • Paul Blair 466 posts 731 karma points
    May 19, 2009 @ 03:43
    Paul Blair
    0

    You can inject some .NET code into your XSLT like so:
    [code]



    [/code]

  • Duke Maximus 23 posts 20 karma points
    May 19, 2009 @ 04:02
    Duke Maximus
    0

    Thanks Spider! that's a lot covered but I'd also like to access settings like ConfigurationManager.AppSettings[] in the web.config file. Would you know how I could achieve this?

    Thanks in advance!

  • Duke Maximus 23 posts 20 karma points
    May 19, 2009 @ 23:39
    Duke Maximus
    0

    Haven't found the perfect resolution but something close.

    I have yet to figure out if I can access the web.config settings directly from XSLT but I've resolved the issue by adding the .net extension which returns the key values.

  • Paul Blair 466 posts 731 karma points
    May 20, 2009 @ 00:53
    Paul Blair
    1

    Here is how i have done it:
    [code]


    ]>
    <>
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
    xmlns:yourprefix="urn:my-scripts"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltStrings">












  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 00:16
    Duke Maximus
    0

    When I try doing something similar to your example, I get an error saying 'The variable or parameter 'string' is either not defined or it is out of scope.'

  • Paul Blair 466 posts 731 karma points
    May 21, 2009 @ 02:45
    Paul Blair
    0

    Is the value you are trying to retrieve in the appsettings section of the web.config?

    Can you post your whole script here and I'll take a look?

  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 03:55
    Duke Maximus
    0

    Hi Spider,

    this is the full xslt file.


    [code]
    ]>

    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:search="urn:search"
    xmlns:searchTest="urn:testscripts"
    xmlns:umbraco.library="urn:umbraco.library"
    xmlns:RegularExpression="urn:Exslt.ExsltRegularExpressions"
    exclude-result-prefixes="search umbraco.library RegularExpression">










    [/code]

    Note that 'umbracoNodeExceptions' is something I've added in the config file.

  • Duke Maximus 23 posts 20 karma points
    May 21, 2009 @ 05:56
    Duke Maximus
    0

    This is working now! Don't know what I changed but I hope it sticks. Thanks Spider!

  • Paul Blair 466 posts 731 karma points
    May 21, 2009 @ 06:09
    Paul Blair
    0

    np, glad you got there :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies