Unwanted Characters on Website Page

If you see any unwanted characters on any of your pages on your website, check the encoding of the page. If the encoding is not proper, it may add noisy characters to your pages in website. If the unwanted characters are like , which is called byte order mark (BOM) simply open the page in notepad. Go to menu File>>Save As. In the file save as dialog box select the encoding as ANSI And then save the file with the same name.

Also, if the characters are something else, save the file with the encoding as “iso-8859-1”. And it should work the way you wanted.

If you have some new unwanted characters please post them on this site through ‘Leave a suggestion’ section at bottom of any page.

Upload this modified page to the server or where ever your files are and then check the page again. Try deleting the browser’s cache and check again if it didn’t work for the first time.

Sort XML Attribute using XSLT | Sort XML by Date using XSLT

This is an approach to solve the date sorting problem in XML and XSLT. This article gives an example to sort XML attribute using XSLT. The attribute is date here – so it XSLT sorts the XML by Date. The date is a simple string “dd.mm.yyyy”. The following example is a code snippet to solve this problem.

Code to sort XML attribute using XSLT

To check this, copy the xml below in data.xml, copy the xslt code in style.xslt. Store them in same directory and view the XML in Browser.

The XML

          <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="style.xslt"?>
<birthdays>
<item>
<date>13.05.2005</date>
<title>John</title>
</item>
<item>
<date>06.02.2000</date>
<title>Steve</title>
</item>
<item>
<date>13.01.2007</date>
<title>Lisa</title>
</item>
<item>
<date>29.05.2010</date>
<title>Sarah</title>
</item>
</birthdays>

The XSLT

          <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"
 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="birthdays">
<h1>Birthdays</h1>
<ul>
<xsl:for-each select="item">
<xsl:sort select="normalize-space(substring(date,7,4))" order="descending" />
<xsl:sort select="normalize-space(substring(date,4,2))" order="descending" />
<xsl:sort select="normalize-space(substring(date,0,2))" order="descending" />
<li>
<xsl:value-of select="date" />
<br />
<xsl:value-of select="title" />
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>

You’ll see the following output

The Output

Birthdays

  • 29.05.2010
    Sarah
  • 13.01.2007
    Lisa
  • 13.05.2005
    John
  • 06.02.2000
    Steve

The parameter order=”descending” sorts the date in descending order. To sort in ascending, change descending to ascending. Normalize space is used to ignore or trim the leading or trailing spaces to help perform the sort function correctly. Substring chooses the particular part of date from the date string. If your date is in a format other than dd.mm.yyyy, you’ll need to change the values in substring function call above.

Running into issues?! Discuss below.

How To Include Xsl in Xml

You can refer a css or a javascript file in an html page so whenever that html page is opened in a browser, it renders with the styles and the functionalities enabled. Similarly, this article teaches How To Include Xsl in Xml. There is a way to include or link a xslt stylesheet to display the xml with styles making it more readable.

how to Include Xsl in Xml

How To Include Xsl in Xml

The following xsl is a very basic code sample to demonstrate the xslt include in xml:

The XSL

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="mytext">
<h1>
<xsl:value-of select="myhead" />
</h1>
<p>
<xsl:value-of select="mypara" />
</p>
</xsl:template>
</xsl:stylesheet>

The XML

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="style.xslt"?>
<mytext>
<myhead>Demo: How To Include Xsl in Xml</myhead>
<mypara>This demonstrates the way to include the xslt so it
 renders in the browser with a readable format.</mypara>
</mytext>

Save the above XML as data.xml and the xsl code as style.xslt. And then see the following output in the browser.

To view in browser, select the data.xml file and right click then select Open with> Internet Explorer (or your favorite browser)

The Output

Demo: How To Include Xsl in Xml

This demonstrates the way to include the xslt so it renders
in the browser with a readable format.

Dynamic printing using different trays in Smartforms

This article explains how we can do the dynamic tray interchange for printing of smartforms in other words – Dynamic printing using different trays in Smartforms.

Dynamic printing using different trays in Smartforms

Requirement: There were two pages for delivery note which needs to be printed from two different tray’s of the printer. Reason behind this is, One tray will contain pre-printed stationary and other will have normal paper. This was something which I had never done and I was not able to locate anything from the web so thought of creating page for the benefit of others.

Analysis:  SAP has provided one field in the smartform where we can specify the resources for printing and there we can define the trays. But it is totally static; with the help of ABAP we can make it dynamic to achieve such requirement that I did for my client.

The screenshot shows the resource field available on the Smartform to specify static tray of printer.

 

Realization:  So the realization of this requirement is explained below:

 

  • This requirement was for the Delivery note smartforms.
  • In the requirement the main page of Del Note needs to be printed on the pre-printed stationary and the item texts will be printed on the normal page.
  • The pre printed stationary will be kept in either of the Tray of the printer that total depends upon the configuration i.e., it is totally dynamic we have to change the trays dynamically on the runtime.
  • In my case the configuration will be done on the basis of output type I think it will remain same throughout the SAP for smartform printing.

The screen shots below shows the step by step reliazation of the functionality:

  • Declare constants in the Initialization part of the smartforms.

  • These are the values which we can pass in the field Resource name.
  • As per my clients specification the Printer name will be configured like   ‘ABC_T1’ for Tray 1,’ABC_T2’ for Tray 2 and so on.
  • ·In the Initialization part we need to capture the name of the Printer specified by the user.

 

In the screen shot above  we need to specify the Dynamic trays’s If there is item text available otherwise no need of dynamic conversion.

So If the item text is available we are using Conversion exit to get the actual printer name as specified by the user.

Import nast-ldest and in the variable l_printer you will get the name of the printer.

  • As specified in the above point that the naming convention of printer will contain ‘_T1’ for tray 1 and like that, we are checking the variable for the specified string and accordinglly assigning the tray number to the variable.
  • After assigment of the variable we have to pass these variables to the resource name field. As shown below.

  • By this dynamic tray interchange for printing of smartforms can be achieved.

– submitted by Aashish

Resolving Error 40607 – Windows logins are not supported in this version of SQL Server

This is based on my experience and resolution of the issue Windows logins are not supported in this version of SQL Server [Error 40607].

The issue was occurring while running the application which was associated with the database on another server. The problem was in the connection string. The developer had developed the application with Integrated Windows Security which did not work for this kind of application I believe where the server is not the same (localhost).

The Integrated Security should be set to false or should be removed altogether to overcome this issue. 

The User Name and Password information may be added:

<add name="DefaultConnection" connectionString="Data Source=DatabaseServerName;Initial Catalog=DatabaseName;MultipleActiveResultSets=True;User ID=DatabaseUserName;Password=DatabasePassword" providerName="System.Data.SqlClient" />

Let me know if this one was helpful.

HTML5 Session Storage

  • Stores data for one session
  • The data is deleted when the browser’s window is closed.

<script>
    sessionStorage.variableName = "value";
    alert(sessionStorage.variableName);
    sessionStorage.removeItem("variableName");
    alert(sessionStorage.variableName);
</script>

HTML5 Local Storage

HTML5 Local Storage

Let’s discuss what HTML5 Local Storage is all about.

  • HTML5 Local Storage stores data with no time limit,
  • Data can be accessible at anytime and any windows/tabs (with some conditions like same domain and same browser) even if the browser is restarted.

<script>
    localStorage.variableName = "value";
    alert(localStorage.variableName);
    localStorage.removeItem("variableName");
    alert(localStorage.variableName);
</script>

HTML5 Storage

  • No more web browser’s cookies storage needed (unless required).
  • HTML5 has introduced a new way to store the data in user’s browser, known as client-side storage.
  • HTML5 offers two new methods for storing data on user’s browser, which are localStorage and sessionStorage.

Windows Azure Error failed to start storage emulator the sql server instance localhost sqlexpress could not be found

Resolving: Windows Azure Error failed to start storage emulator the sql server instance localhost sqlexpress could not be found

You need to run DSInit utility to create database. For Windows Azure SDK 1.6 the location for DSInit utility is:

C:Program FilesWindows Azure Emulatoremulatordevstore

By default DSInit expects that your database server is (local)SQLEXPRESS but you can change it easily. If you have MSSQL instance called SQLEXPRESS then it is enough to just run DSInit. If you need some other instance then run the following command:

DSInit /sqlinstance:<instance name>

For default instance use “.” as instance name:

DSInit /sqlinstance:.

You can find more information about sqlinstance and other switches from DSInit documentation. If database was correctly created you should see dialog like this:

DSInit: Strorage databases are done

When storage database is ready you can run your application.