Wednesday, January 9, 2013

Sort date in Xml using XSLT

Here is how we can sort in given XML using XSLT



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
  <xsl:output method="text"/>
  <xsl:template match="Records">
    <xsl:apply-templates>
         <!-- year part -->
         <xsl:sort select="substring-after(substring-after(@OrderDate,'/'),'/')"    />
         <!-- month part -->
         <xsl:sort select="substring-before(substring-after(@OrderDate,'/'),'/')"  />
         <!-- day part -->
         <xsl:sort select="substring-before(@OrderDate,'/')"       />
          </xsl:apply-templates>
  </xsl:template>
  <xsl:template match="Order">
     <xsl:if test="position() = 1">
   <xsl:value-of select="@OrderDate"/> <br/>
   </xsl:if>
    </xsl:template>
</xsl:stylesheet>


To test the functionality use the following Sample XML. Use the below Url to test http://www.w3schools.com/Xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog

<root>
    <Records>
         <Order OrderDate="14/01/2011"> </Order>  
          <Order OrderDate="05/01/2011"> </Order> 
          <Order OrderDate="08/01/2011"> </Order>  
          <Order OrderDate="10/01/2011"> </Order>  
   </Records>
</root>

Monday, April 9, 2012

Sql Authentication and Windows impersonation


Recently i was working on a BCS solution in SharePoint 2010 and realized a scenario where i have to authenticate SQL Server database with a windows user account for all authenticated users using a connection string.
after trying a good four hours on topic i found there is no easy way where you can provide a service windows account as an account for sql authentication in connection string. so i used a sql server account for such impersonation in connection string with username and password.
 
but the question was still in my mind for is it the way designed or i missed something which i should know. Then i thought to explore and i found it true. WHY?, next question you might put up and the reasons are below
  • When integrated security is "true" or "SSPI" What is SSPI? the basic assumption it uses current thread's identity for authentication with SQL Server, so impersonate the current thread to achieve the scenario.
  • With windows impersonation in sql server connection string might trouble you incase your enterprise wide password maintenance policy (i.e. change password every quarter).
  • Risk of identoty theft i.e. you need to know the password of windows user (although service dummy account can be used to overcome this factor but it again becomes overhead for It support team).
Further Readings:

Thursday, December 1, 2011

Invalid look up error in SharePoint 2010

Invalid look up error in Sharepoint 2010 when try to upload document in Library
Genrally when we download or migrate a document from one sharepoint library to another, document contains metadata also. the same metadata conflict when there is already a a same column also in new library but with different datatype e.g. string and managed metadata

To resolve the issue follow Open Document and Go to File menu &gt; Properties and  select custom tab in window&gt; find if any of the value conflicting with existing columns in document library
this should be most probably Document type/ Author etc.

delete the property and upload the document again. these settings applies to Word 2003 documents. similar can be found in word 2007/2010 documents