SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im having a problem placing the XsltListViewWebPart on my Default.aspx template (relevant code bellow)

<WebPartPages:WebPartZone runat="server" ID="NewsItemsList">
        <WebPartPages:XsltListViewWebPart AllowPartiallyTrustedCallers="TRUE" runat="server" ListUrl="Lists/NewsItemsListInstance" ID="NewsItems" DisplayName="" ChromeType="None" ViewGuid="{00000000-0000-0000-0000-000000000000}">
                <View Name="MyView" Default="True" Type="HTML" Hidden="TRUE" TabularView="FALSE" DisplayName=" " Url="View.aspx" Level="255" BaseViewID="2" ContentTypeID="0x01000627D3E6EEDA4DCD9F403FE5F9A66E45" ImageUrl="/_layouts/images/generic.png">
                        <FieldRef Ascending="FALSE" Name="ID"/>
                        <FieldRef Ascending="FALSE" Name="Callout"/>
                        <FieldRef Name="Attachments"></FieldRef>
                        <FieldRef Name="LinkTitle"></FieldRef>
                        <FieldRef Name="Callout"></FieldRef>
                        <FieldRef Name="Icon"></FieldRef>
                    <RowLimit Paged="TRUE">6</RowLimit>
                    <Aggregations Value="Off"/>
                    <Toolbar Type="Standard"/>

            <XslLink>/Style Library/insight/xsl/NewsPortal.xslt</XslLink>

when I browse to the template I receive the following error

Access denied. You do not have permission to perform this action or access this resource.

This only appears when i try to use the

<XslLink>/Style Library/insight/xsl/NewsPortal.xslt</XslLink>

element if I remove this then the error goes away. This has put me in a catch 22 situation because I can style the default view of the list through the schema.xml used to provision the list, however this styles all views of the list.

Is there even a way to specify this webpart to use a specific BaseViewID? if so what is it?

happy to provide more information if needed

Thanks in advance



This is the ULS log error

Error while executing web part: System.UnauthorizedAccessException: <nativehr>0x80070005</nativehr><nativestack></nativestack>
at Microsoft.SharePoint.Library.SPRequest.UpdateWebPartCache(String bstrWebUrl, Boolean bAllUsers, String bstrID, Byte[]& ppsaData, Boolean fOMCall)
at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CacheWriteInternal(Guid storageKey, Byte[] cacheData, Storage storage, Boolean omCall)
at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.get_CustomizedXsl()
at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.LoadXslCompiledTransform(WSSXmlUrlResolver someXmlResolver)
at Microsoft.SharePoint.WebPartPages.DataFormWebPart.GetXslCompiledTransform()
at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform)


I have checked the style library to see if the xsl is provisioned and i have discovered somthing that may be of use in solving this. In the GUI view the file does not exist to my user

Image of all content with file not existing

However if I type in the URL the file can be found.

Download box proving existance

Could this be what the webpart is complaining about? and if so how can i give the webpart access to the xslt?



Update 3

I have tried using mapped folders to provision my XSL

and I can view the XSL through the browser ie browsing to the mapped folder.


but the webpart generates this error in the browser

Access Denied. You do not have permission to perform this action or access this resource

I have done a bit of reading around and found that webpart security has been enhanced in sharepoint 2010 and have found the following link which are suggesting that the way forward is to edit the web.config.

however I struggle to believe this is the truly the case that I need to lower the security levels to just set a predefined property of the webpart (XslLink) can someone please confirm or deny that this is the case.



Update 4

A bit more googling has yeilded the fact that there is indeed a "feature" in sharepoint 2010 xslt list view webpart in that an anon user cannot set the xsl or xsllink property.

This has now brought me back full circle in that I need to provide a styled list view to users and also a traditional allItems.aspx view to editors where they can update the content of their list any suggestions greatly welcome as I am running out of ideas on this one :-S



Update 5

Right I have carried on googling and cannot find a solution to this, I am however pretty confident that the collective mind of SO can. I am also convinced seeing the number of posts on various forums around the web that I am not the only person that has this issue.

So I am going to put this up for bounty as soon as I am aloud as I feel that the solution to this can benefit the sharepoint community.

share|improve this question
Tried escaping the URL by using %20 for Spaces, e.g. <XslLink>/Style%20Library/..... – Marius Constantinescu - MVP Aug 7 '12 at 15:25
@C.Marius yes and it still doesn't work :-( but thank you for the suggestion. – Nicholas King Aug 7 '12 at 15:32
up vote 5 down vote accepted


The bug of trying to set the xsllink property through the template seems to be a recognised bug. I'm even sure MS are aware of this as when looking at how they have created their site definitions it seems pretty uninstinctive.

The Solution


instead just define a webpart zone as shown.

<WebPartPages:WebPartZone runat="server" ID="NewsItemsList" />


We can now define our view in the schema.xml of our list definition.

Schema.xml location

inside of schema.xml are a series of views with unique BaseViewId's.

<View BaseViewID="2" Type="HTML" Name="NewsStories2" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">NewsPortal.xsl</XslLink>
        <RowLimit Paged="TRUE">6</RowLimit>
            <FieldRef Name="Attachments"></FieldRef>
            <FieldRef Name="LinkTitle"></FieldRef>
            <FieldRef Name="Callout"></FieldRef>
            <FieldRef Name="Icon"></FieldRef>
                <FieldRef Name="ID"></FieldRef>
            <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
            <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />

you can use the

<XslLink Default="TRUE">NewsPortal.xsl</XslLink>

property to set the location of the xsl in order to render the view.

All that is required now is placing the xsltlistview webpart inside of the template. This is done through the onet.xml.


<Module Name="DefaultBlank" Url="" Path="">
  <File Url="default.aspx">
      <View List="Lists/NewsItemsListInstance" BaseViewID="2" WebPartZoneID="NewsItemsList" WebPartOrder="1">
                        <webPart xmlns="">
                                <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                                <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                                    <property name="AllowConnect" type="bool">True</property>
                                    <property name="ChromeType" type="chrometype">None</property>
                                    <property name="AllowClose" type="bool">False</property>


on the view element.

according to the MS schema

List = location of the list either integer or text(the texl url can be grabbed from the list instance elements.xml mine is shown below)

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
  <ListInstance Title="News Items List"
            <!--Feature ID Correlates to a user defined site scoped feature containing the list definition//-->
            Description="My List Instance"

BaseViewId = The BaseViewId that you defined in the schema.xml and wish to use to render this view inside of the webpart.

WebPartZoneID = The Id property set on the webpartzone that is defined in the template where you wish for the xsltlistviewwebpart to be rendered.

I hope this answer helps someone as we have spent over a week trying to get this to work and it has essentially stopped all progress on our project. I hope to upload an image which hopefully will clarify the relationships between the sharepoint objects(xml files) more a later time.




As promised here is an image illustrating how to provision the list, site definition and xsltlistviewwebpart successfully. No more 'Access denied' errors :-)

How to provision a site

share|improve this answer

Ok I'm going to kick off the answers with a potential answer which I don't really like but still.

suggests that you can set the xsllink property through powershell however, this seems like a slight hack.


$spweb = Get-SPWeb ""; 
$url = $spweb.Url; 
$WebPageUrl = "/Pages/test.aspx"
$spWpManager = $spweb.GetLimitedWebPartManager($WebPageUrl,[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared); 
foreach($spwebpart in $spWpManager.Webparts) 
 $spwebpart.xsllink="_layouts/xsl/tony.xsl"; #set the web part property

and I don't really feel all that comfortable proceeding with this approach. as it means writing a script to change the property of the xsllink in every instance of the xsltlistviewwebpart. Im hoping that a better solution is proposed, otherwise this may be the route that I go down.



share|improve this answer

I ran into this issue. The problem seems to be XSL transform caching. Specifically anonymous / vs authenticated users.

An alternate solution is to add your xsl inline with the view. Just after the closing DataFields tag, add your XSL.

<!– Add your custom xsl here –>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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