Click on this icon to open the XML page.Tom Van Gaever - Blog
Search:   

SharePoint 2010 and XSL - The XML Viewer Web Part - Weather Information - Lesson 1 
Sunday, October 17, 2010, 20:07 - SharePoint
Posted by Administrator
In SharePoint 2007 we could very quickly create a powerful solution without using a single line of server code. The key component for this solution was using SharePoint Designer, the Data View Web Part and XSL. In SharePoint 2010 they have provided us with a web part that allows providing the specific location of an xml file and the location of an xsl file.

The location of the xml file can of course be any link that provides xml, for this demonstration I would like to keep it easy and show that SharePoint 2010 has the mechanisms provided to communicate with other external systems.

1) Add an XML View Web Part to your SharePoint page and open the properties pane


2) Specify the following url in the XML link textbox (http://www.google.com/ig/api?weather=Brussels). As you can see in the url, I've provided Brussels as current location. Of course you are free to provide the city where you are currently located to retrieve your local weather forecast.


3) Provide the following lines of xml in the XSL editor (this xsl will retrieve all the transform all the data from the xml, but there is no css style applied


	
		
		
		
		
			
			http://www.google.com:value-of select="xml_api_reply/weather/current_conditions/icon/@data"/>
			
		
		
		
°C
http://www.google.com
min: °C - max: °C


4) The next xsl snippet has some Cascading Style Sheet embedded. Feel free to reuse it as a base for your own custom style.


	
	
		
		
		
		
		
Current
http://www.google.com
°C
Forecasts
http://www.google.com
min: °C - max: °C


This should be the result in your page:


The web part can also be downloaded from here;
http://tomvangaever.be/blog/sp2010/tvg- ... ebpart.dwp


6 comments ( 145 views )   |  permalink   |  related link   |   ( 3 / 8466 )
Important: ASP.NET Security Vulnerability  
add comment ( 41 views )   |  permalink   |  related link   |   ( 2.9 / 1618 )
JQuery and IE6: Xml result from webservice could not be parsed using find() 
Monday, September 20, 2010, 08:25 - SharePoint
Posted by Administrator
Although IE6 is not supported by SP2010 I don't want to eliminate all the IE6 users from my webpart. This webpart is calling a Siebel webservice with data regarding the current loggedin user.

While developing in IE7 everything was perfect (both FF and IE worked like a charm, but IE6 didn't show a single result, but also no errors)

It seemed that the XML traversing did not work in IE6, after using my favourite search engine I found this wonderfull script that would help solve my issue very efficient!

    var DataUtilities = (function() {
    //Privileged variables and methods
    var self = {
    "processXML": function(xml) {
    if (!jQuery.support.htmlSerialize) {
    //If IE 6+
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.loadXML(xml);
    xml = xmlDoc;
    }
    return xml;
    }
    };
    return self;
    })();


it is very easy to use

var xml = DataUtilities.processXML(xData.responseText);


After adding this little fix it worked like a charm again!


1 comment ( 26 views )   |  permalink   |  related link   |   ( 3 / 1513 )
Create SharePoint Service Accounts By Using PowerShell 
Friday, July 23, 2010, 11:19 - SharePoint
Posted by Administrator
This script will automate the process of service accounts creation in SharePoint 2010. The solution exists in 2 parts. The first part is a CSV file, called sp2010_service_accounts.csv, where you can specify the service accounts you need. The second part is a powershell script called SP_ServiceAccounts.ps1.

1) Download the zip file from here (http://tomvangaever.be/blog/powershell/ ... rShell.zip)

2) Extract the script to, for example, c:\yourname

3) Run powershell and navigate to c:\yourname


4) Execute SP_ServiceAccounts.ps1

- When you receive an error saying that you cannot execute the powershell script, please enter Set-ExecutionPolicy Unrestricted.The reason for this error is the security setting on your pc that does not allow you to execute a script. This is the so-called Execution Policy. By default, the Execution Policy is set to Restricted. This setting means that you may not run any PS1 script at all.

An overview of the policy levels:
Restricted: Individual cmdlets can run, but not saved Powershell scripts. This is the default setting.
AllSigned: Scripts can run, but must have a digital signature even if written on the local computer. Prompts you before running scripts from trusted publishers.
RemoteSigned: Scripts written on the local computer do not need a digital signature, but any script downloaded from outside (email, IM, Internet) must have a signature to execute.
Unrestricted: Any script can run, but scripts downloaded from outside will run with a warning.


- The first parameter you need to specify is the OU you would like to create for the service accounts.
(for example: SP Service Accounts)

- The second parameter is the location of the csv file containing the service accounts.
(for example: c:\yourname\sp2010_service_accounts.csv)



5) When everything went right, the service accounts specified in the CSV file are created for you in 5 seconds.


Job's done!

PS: I've included the service accounts in the CSV file for you ;)
add comment ( 14 views )   |  permalink   |  related link   |   ( 3 / 1635 )
Reflections on System.Reflection: To GAC or not to GAC 
Friday, July 16, 2010, 08:27 - General
Posted by Administrator
While creating a Visual Studio 2010 VSIX , I'm using reflection to inspect the project dll. While using this assembly's types, my addin creates other files in the solution... This enables me to generate code that would take me hours to write (I love this sentence!). But in this scenario I learned some things about reflector I haven't had any issues with before, probably because it wasn't in this particular scenario... I hope you didn't knew it already ;)

1) Load an assembly that is also deployed in the Global Assembly Cache or GAC
When you use the Assembly.LoadFrom(string assemblyFile) method, you'll notice that the assembly you load is not the assembly in the folder that you specified in your parameter, but it is the assembly that you have installed in your GAC. naturally when the assembly is not installed in the GAC, there is no issue ;)




But what if, like in my case, you would like to analyze a Type in a dll... And you would like to analyze the dll in the project bin folder and not the one in the GAC? Consider this quote regarding reflection:
You can load a disk-based assembly with the same identity as one in the GAC. If you tried this with LoadFrom or LoadFile, the GAC assembly is ALWAYS loaded.

In my case this is the not the behaviour I need, what I need is the Assembly.ReflectionOnlyLoad and the Assembly.ReflectionOnlyLoadFrom methods. It is important to know that these 2 methods only reflect the assembly, which basically means that you cannot load them... if you do try to load them, you'll receive an InvalidOperationException.

The solution?
By using the Assembly.ReflectionOnlyLoadFrom() method you are always analyzing/inspecting the dll you specified as a parameter.




2)the assembly dll is locked after using Assembly.ReflectionOnlyLoadFrom()
It seems that by using the LoadFrom methods will put a lock on the dll, this is not interesting for me because I would like to change the dll by building in in Visual Studio and then inspect it again... The resolution seems rather to easy!





The solution?
Assembly assembly = Assembly.ReflectionOnlyLoad(System.IO.File.ReadAllBytes(dlllocation));

More information:
http://msdn.microsoft.com/en-us/library ... embly.aspx
http://msdn.microsoft.com/en-us/library/0et80c7k.aspx
http://stackoverflow.com/questions/5701 ... ly-reflect
http://stackoverflow.com/questions/3058 ... ononlyload

Issue resolved, have a nice day!
1 comment ( 41 views )   |  permalink   |   ( 2.9 / 994 )

<<First <Back | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Next> Last>>