Create dynamic checklistbox using xsl

When we use database we design Item table like following:

ID Name Description Price Per Unit Batter Topping Quantity
0001 Cake Chocolate Cake 0.55 Regular Maple 100
0002 Cake Blueberry Cake 0.55 Blueberry Maple 200
0003 Raised Raised Glazed 0.55 Regular Glazed 150
0004 Buttermilk Chocolate Buttermilk 1.55 Chocolate   180
0005 Bar Chocolate Bar 0.75 Regular Maple 100

The XML file structure looks like this:

<?xml version=”1.0″ encoding=”utf-8″?>
   <Item>
        <ID><![CDATA[0001]]></ID>
        <Name>Cake</Name>
        <Description><![CDATA[Chocolate Cake]]></Description>
        <PricePerUnit>0.55</PricePerUnit>
        <Batter>Regular</Batter>
        <Topping><![CDATA[Maple]]></Topping>
        <Quantity>100</Quantity>
   </Item>
   <Item>
        <ID><![CDATA[0002]]></ID>
        <Name>Cake</Name>
        <Description><![CDATA[Blueberry Cake]]></Description>
        <PricePerUnit>0.55</PricePerUnit>
        <Batter>Blueberry</Batter>
        <Topping><![CDATA[Maple]]></Topping>
        <Quantity>200</Quantity>
   </Item>
   <Item>
        <ID><![CDATA[0003]]></ID>
        <Name>Raised</Name>
        <Description><![CDATA[Raised Glazed]]></Description>
        <PricePerUnit>0.55</PricePerUnit>
        <Batter>Regular</Batter>
        <Topping><![CDATA[Glazed]]></Topping>
        <Quantity>150</Quantity>
   </Item>
   <Item>
        <ID><![CDATA[0004]]></ID>
        <Name>Buttermilk</Name>
        <Description><![CDATA[Chocolate Buttermilk]]></Description>
        <PricePerUnit>1.55</PricePerUnit>
        <Batter>Chocolate</Batter>
        <Topping><![CDATA[]]></Topping>
        <Quantity>180</Quantity>
   </Item>
   <Item>
        <ID><![CDATA[0005]]></ID>
        <Name>Bar</Name>
        <Description><![CDATA[Chocolate Bar]]></Description>
        <PricePerUnit>0.75</PricePerUnit>
        <Batter>Regular</Batter>
        <Topping><![CDATA[Maple]]></Topping>
        <Quantity>100</Quantity>
   </Item>

In XSL file we have a CkecklistBox. We need to fetch all Item name from the Items.xml file. The default file for OptDialog.xsl file is OptDialog.xml file. We have to add two templates to display checklistbox with item names.

<xsl:key name=”XmlItem” match=”Identification” use=”Name”/>
  <xsl:variable name=”itemnames” select=”document(‘Items.xml’)” />
 <!– collect all catalog names for checklistbox –>
  <xsl:template match=”itemnames/Item/Name” name=”XmlItemref”>
    <xsl:variable name=”ItemName”>
 <!– fetch all item name and store into ItemName variable–>
    <xsl:variable name=”elemName” select=”$itemnames/Item/Name”/>
    <xsl:for-each select=”$elemName”>
      <xsl:value-of select=”.”/>,
    </xsl:for-each>
    </xsl:variable>
 <!– add checklistbox for display item name–>
    <div style=”background-color:white;height:200px;width:100px;font-family:Verdana; font-size:8pt;float:left;overflow-y:scroll;overflow-x:visible;position:relative;” name=”lstItemNames” id=”lstItemNames” OnClick=”JavaScript:getItemName();”>
      <xsl:attribute name=”scope”><![CDATA[report]]></xsl:attribute>
      <xsl:attribute name=”xpath”><![CDATA[//Item/Name]]></xsl:attribute>
  <!– call item-tokenize template to split items–>
      <xsl:call-template name=”item-tokenize”>
        <xsl:with-param name=”list” select=”$ItemName” />
        <xsl:with-param name=”delimiter” select=”‘,'”/>
      </xsl:call-template>
    </div>
  </xsl:template>

The item-tokenize tamplate:

<!– split string tokenizer Template –>
  <xsl:template name=”item-tokenize”>
    <xsl:param name=”list” />
    <xsl:param name=”delimiter” />
    <xsl:variable name=”newlist”>
      <xsl:choose>
        <xsl:when test=”contains($list, $delimiter)”>
          <xsl:value-of select=”normalize-space($list)” />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select=”concat( normalize-space($list), $delimiter )”/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name=”first” select=”substring-before($newlist, $delimiter)” />
    <xsl:variable name=”remaining” select=”substring-after($newlist, $delimiter)” />
    <xsl:element name=”newitem”>
      <INPUT NAME=”chkOptions” TYPE=”CHECKBOX”>
        <xsl:attribute name=’value’>
          <xsl:value-of select=”$first”/>
        </xsl:attribute>
      </INPUT>
      <xsl:value-of select=”$first”/>
    </xsl:element>
    <xsl:if test=”$remaining”>
      <xsl:call-template name=”item-tokenize”>
        <xsl:with-param name=”list” select=”$remaining” />
        <xsl:with-param name=”delimiter”>
          <xsl:value-of select=”$delimiter”/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

Now call the template into table to display the checklistbox:

<TABLE width=100%border=0cellpadding=5style=font-family:Verdana; font-size:8pt>

<TR>

<TD colspan=2“>

<xsl:call-template name=XmlItemref>

</xsl:call-template>

</TD>

</TR>

</TABLE>

The output is given below:

Show message from string table in C#

1. Run Microsoft Visual Studio 2010 and create a new windows application(File->New->Project)

2. Select Windows FormsApplication and enter application Name into Name field “TestMessage”

3.  Add a button from Toolbox, enter ‘Show Message’ into Text property, ‘btnShowMessage’ into Name property

4. Double click on the button to go to the class file

5. Add tow reference:

using  System.Resources;

using System.Reflection;

6. Go to the design view and right click on the project solution name in solution view, select Add->New Item, select Resource File and click on ‘Add’ button. A file named ‘Resource1.resx’ will add to your project

7. Double click on the resource file and enter “This is a test” into value field. default name field is String1. save the file

8. Add following code into Form1 class scope:

public partial class Form1 : Form
    {

        private static ResourceManager RM;
       
        public static void initialise()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            RM = new ResourceManager(“TestMessage.Resource1”, assembly);
        }
        public static string Getstring(string key)
        {
            return RM.GetString(key);
        }

}

9. To initialize the file add following code into default constractor of the class:

public Form1()
        {
            InitializeComponent();
            initialise();

        }

10. Double click on the button and add the code:

private void btnShow_Click(object sender, EventArgs e)
        {
            MessageBox.Show(Getstring(“String1”));
        }

11. Compile and run the project, click on the button.It will display message from string table

XSLT(Extensible Stylesheet Language Transformation)


XSLT (Extensible Stylesheet Language Transformation) is a language for transforming XML document into XML, HTML, XHTML, or plain text documents. XSLT serves us many ways:
1. It is a general-purpose translation tool.  It convert from one XML markup vocabulary to another. XSLT transform an XML document into HTML or XHTML so it will easily display in a web browser.
2. It can recognize document content
3. It can generate multiple results from the same content-like HTML, SVG and WAP
4. It uses XPath for navigating XML documents. XPath helps XSLT identify and find nodes in XML documents. Nodes are things like elements, attributes, and other objects in XML.
5. It help us to perform complex sorting and linking easily.
XSLT will create a new XML document based on the content of existing xml file without changing it. It is most often used to convert xml data into web pages/PDF, between different xml schemas.  It is developed by World Wide Web Consortium(W3C). The latest version is 2.0.

In XML document the order of element is meaningful but the order of attribute is not meaningful, comments are same as html comment, CDATA sections often used to ‘markup’ into an element. Like –

<Name><![CDATA[John Smith]]></Name>

<City><![CDATA[Dhaka]]></City>
<State><![CDATA[Bangladesh]]></State>
<Country><![CDATA[Bangladesh]]></Country>
<Zip><![CDATA[1234]]></Zip>

Default Rules of XSLT Processing:

  • Document node: xsl:apply-templates
  • Element nodes: xsl:apply-templates
  • Text nodes: output text

From Architectural Point of View:

  • XML Parser – An XML Parser is the component that interprets the XML code. Codes cannot be understood without a parser. An XML parser provides vital information to the program on how to read the file. Parsers come in multiple formats and styles. They can be free-standing software, libraries, modules and classes. All browsers have built-in XML parsers.
  • XSLT Processor – The software responsible for transforming source trees into result trees using an XSLT stylesheet is referred to as the processor.
  • Serialize – serialize the xml document for view the final output

How Does The Parser Work:

Parsers can be a bit complex. The goal is to transform XML into a readable code. Computer hardware only knows one language. It is the software that turns all the different languages into a workable format. Software is smart, but computers by themselves are ignorant. When presented with a bunch of XML code, computer hardware has no clue what it means. Parsers convert that code into something the hardware will recognize.

How XSLT Processor Work:

  1. Loads the input document as a DOM tree (internally the processor optimizes DOM)
  2. Performs a depth-first walk of the input tree
  3. As it walks through the document, selects a template in the stylesheet for the current node
  4. Applies the template, which describes how to create zero, one, or more nodes in the output tree
  5. When the walk is completed, creates a new tree (the output tree) from the input tree and the rules in the templates
  6. Writes the output tree according to the HTML or XML syntax

How Does Serialize The Result:

After your application has evaluated an XPath or XQuery expression or performed a transformation with an XSLT stylesheet, you might want to write the output as an actual XML document represented as a file or as a Java™ string. The process of rendering results as an XML document is known as serialization.

Procedure

  • Serialize an XSequenceCursor.

    Your application can call the XSequenceCursor.exportSequence method to serialize a sequence that is represented by an instance of the XSequenceCursor interface. The arguments on this method are an instance of the javax.xml.transform.Result interface and optionally an instance of the XOutputParameters interface.

    If the instance of the Result interface is also an instance of the javax.xml.transform.stream.StreamResult class, the sequence is serialized as described in the XSLT 2.0 and XQuery 1.0 Serialization Recommendation. The StreamResult object can contain an instance of the java.io.Writer class or the java.io.OutputStream class, where the processor will write the serialized sequence.

    You can create an instance of the XOutputParameters interface by calling XFactory.newOutputParameters() and call the methods on that object to override the default serialization parameter settings.

    XFactory factory = XFactory.newInstance();
    XPathExecutable expr = factory.prepareXPath("/purchaseOrder/item[@price > 1000]");
    XSequenceCursor exprResult = expr.execute(new StreamSource(inputFile));
    
    System.out.println("Items purchased costing more than $1000");
    if (exprResult != null) {
        // Set indenting in order to pretty-print result
        XOutputParameters params = factory.newOutputParameters();
        params.setIndent(true);
        exprResult.exportSequence(new StreamResult(System.out), params);
    } else {
        System.out.println("None found");
    }

    You can also call one of the getOutputParameters() methods on an instance of the XSLTExecutable interface to get the serialization parameters that are associated with a particular output definitionin an XSLT stylesheet. Use the XSLTExecutable.getOutputParameters(javax.xml.namespace.QName) method to get the serialization parameters for a named output definition or the no-argument XSLTExecutable.getOutputParameters() method to get those of the unnamed output definition. You might want do this to perform some post-processing on the result of the transformation using the instance of the XSequenceCursor interface that the transformation produces before serializing the result. If you change the settings of the serialization parameters in the instance of the XOutputParameters interface returned by one of the XSLTExecutable.getOutputParameters() methods, it will not affect the output definition in the stylesheet.

    XFactory factory = XFactory.newInstance();
    XSLTExecutable style = factory.prepareXSLT(new StreamSource("style.xsl"));
    XSequenceCursor xformResult = style.execute(new StreamSource("purchase.xml");
    
    XOutputParameters params = style.getOutputParameters(new QName("my-output-definition"));
    params.setMethod(XOutputParameters.METHOD_XHTML);
    xformResult.exportSequence(new StreamResult("output.html"), params);

    Note that according to the XSLT 2.0 and XQuery 1.0 Serialization Recommendation, a serialization error results if the sequence that is to be serialized contains attribute nodes or namespace nodes. If the sequence that you need to serialize might contain attribute or namespace nodes, get the values of those nodes as strings or some other appropriate type and serialize those values instead.

  • Serialize a single item.

    You can also serialize just the current item in an instance of the XSequenceCursor interface by using one of the exportItem methods. The exportItem methods are inherited from the XItemView interface, so they can be called on an instance of that interface as well.

    As with the exportSequence method described above, the arguments of the exportItem method are an instance of the javax.xml.transform.Result interface and optionally an instance of the XOutputParameters interface. The effect of calling exportItem is identical to the effect of calling exportSequence with a sequence that consists of just the current item.

  • Serialize the result of a transformation or query directly.

    Your application can also serialize the result of an XSLT transformation or XQuery expression directly by supplying an instance of the javax.xml.transform.Result interface on the XSLTExecutable.execute method or XQueryExecutable.execute method. The serialization parameter settings are determined by the attributes of any applicable xsl:output declaration or xsl:result-document instruction in the case of an XSLT stylesheet, and are always the default values in the case of the result of an XQuery expression.

    XFactory factory = XFactory.newInstance();
    XSLTExecutable style = factory.prepareXSLT(new StreamSource("style.xsl"));
    style.execute(new StreamSource("purchase.xml"),
                  new StreamResult("output.xml"));

    If your application supplies an instance of the XResultResolver interface on a transformation, your application can direct each final result tree to a different destination.

  • Use identity transformation.

    You can use the XML API to transform XML data contained in an instance of javax.xml.transform.Source directly to an instance of a javax.xml.transform.Result. This is often referred to as an identity transformation. See Performing basic XSLT operations for an example.

You can also serialize your objects into XML and then apply to the transform XML Object Serializer to XSLT Transformer .

Resources:

1. XSL Transformations (XSLT) Version 2.0
2. Serializing the results
3. How an XSLT processor works
4. CSCI E-153, Web Development Using XML

Install Mac OS X Leopard 10.5.7 on PC Duel Boot Windows XP/ 7

You are a Windows XP/ Vista/ 7 user. Have to install Mac OS X in your machine. There is an easy way to install it with duel boot. There are different types of OSX86 Project available like – iPC, iATKOS, Kalyway, iDeneb etc. I use iDeneb which is a Mac OSX Leopard relase modified by Layne and iHackintosh Team, to run on non-Apple computers. This universal relase can run both on Intel and AMD based machines. The current version, iDeneb v1.3 10.5.7, has EFI support, but it can’t boot on old macines due the less of Non-EFI boot. This drawback has been worked out with Chameleon bootloader, that can install also on SSE2 computers. You should check Hardware Compatibility List (HCL) on OSX86 wiki.

Requirements

* Win XP/7 is already installed
* Free partition (for Mac OSX)
* iDeneb DVD/CD
* OSX86 Tools
* An existing Mac (for preparing the USB/DVD)
* Mac OSX distribution (iATKOS, iDeneb, Jas, etc) (Disclaimer: This is for experimental purposes, if you like the OS, please buy your own Mac OSX!)
* EasyBCD
* TabletMagic (if you want the tablet feature)

Steps to Install are given below:
1. Download OSx86 10.5.x

Go to your favorite torrent site and Download 10.5.x of your favorite flavor among the listed ones. Latest version is 10.5.7. Though 10.5.6 is also a fair deal. Burn the downloaded “.ISO” file to DVD using PowerISO / MagicISO or any other burning software.

2. Create Partition, preparing Disk

In windows XP, 7 or vista, Right click My computer > Manage, click Disk Management. Here create a primary partition with minimum 8GB space, though recommended is 15GB. As I have 500GB HardDisk I create partition with 100GB for each OS. There is no need to format this partition. After Partition is created, right click > Mark Partition as Active.

Burn the OSX86 ISO that you downloaded from torrents on to a DVD and reboot with Boot from DVD. Now you should see Darwin load screen.

3. Booting and starting Installation

As countdown from 10 starts, press F8 key and you will be able to have some more option’s. Now type -v and press enter now entered in VERBOSE mode, this will enable you to see any errors if they occur. In case your screen freezes for more than 10 minutes than note last lines and google them to find out a solution for your problem. If every thing goes fine after 15-30 minutes installation screen appear’s hold your breath we are not quit yet here.

Alternatively, to skip the booting errors, you can try these parameters on Boot: prompt

-cpus=1, -cpus=2.

4. Configuring Installation


After boot, you enter the Graphical interface and you should be able to see a top menu.

From the menu Click Utilities > Disk Utility.

Here, select the destination drive where you want to install Mac OSX.

This will be the same partition we created earlier in step 1.

Now click on ERASE on right hand side and under the format option select “MAC OSX Journaled Extended”, give a name and then click Erase.

The disk will be erased and mounted. Close the disk utility and agree to the terms and conditions, then select the partition which you erased recently.

When you reach the Installation Summary Screen, Click on Customize button

5. Customize the Install

The most important part is this step. Now, choose wisely what all components you need to support your running hardware. Browse at http://wiki.osx86project.org/wiki/index.php/Main_Page Navigate to the HARDWARE section and choose your version(10.5.x) and computer type (Portable/Desktop). This page should give sample hardware examples that people have tested, and modules they have selected.

If you have doubts, you can check the Insanelymac.com forums.

For most of the INTEL based systems Vanilla Kernel works very smoothly & for AMD system try Voodoo kernel. It is recommended to remove all the extra unnecessary languages as they take up about 2 gigs. Also, dont add extra Drivers (.KEXTS) which might cause conflicts. e.g. if You have NVIDIA geforce on your laptop, you should select NVDarwin from the “Graphics” section, not all.

Example:
You will need to select a couple of things:-X86 Patches – > OHR-Driver -> System->USB-Driver -> System->Sound->Voodoo HDA driver-Driver -> System->PS/2 mouse/keyboard->Apple PS/2 driver-Driver -> System->Laptop battery-Driver(for laptop) -> System->NTFS-3G-Network ->Wired->Intel(DO NOT check -Network ->Wireless)

After done Hit Ok.

6. Checking the disk and Installation of System files

Now your disk(DVD) will be checked for consistency, then, installation begins. It will take 20-45 minutes as per your hardware juice. After the installation is over, it will ask for a reboot. Remove the DVD after it has rebooted.

You should be able to automatically boot into OS X at this time.

7. Setting up the Boot Loader

Now that OS X is all working, we have to make the previous installation of Windows XP, 7 or Vista to work.  For this, I`ll  use Chameleon boot loader built-in to OS X. Restart the PC and install it.

You can use the Windows boot loader rather than chameleon boot loader. This helps you prevent re-fixing MAC OS installation when you re-install windows at some time in future.Put in your windows 7 or Vista disk, and boot from it. When installation starts, it prompts for “Recovery”. Select the recovery option. On you will be prompted to choose tools available for recovery. Select “command-line”.

DISKPART> list disk // displays the available HDD
DISKPART> select disk n // select the disk which has windows installation
DISKPART> list partition // list partitions on the selected disk
DISKPART> select partition n // select the partition number where windows was previously installed.
DISKPART> active //sets partition active
DISKPART> exit

REBOOT.

Now your xp/vista /windows 7 should boot, If it doesn’t try this:

Boot with installation disk into windows setup, choose recovery again, and select automated recovery of boot area. Windows should fix the boot automatically, then click Fix and reboot button.

8. Adding MAC to the Boot menu via Windows:

Boot into windows normally and download EasyBCD from google. Open it, click “Add/Remove entries” navigate to “Mac”. Select Type in the dropdown to “Generic x86 Pc” and give some name in the text box below. This name will appear in your boot screen. Click “SAVE” when done and REBOOT.

Now you should be able to boot into both MAC OS X Leopard and Windows.

Now enjoy the wonderful world of MAC!

Tips for Mac user to capture screenshot

How many ways you can capture your screen using Mac OS X:
1.Command-Shift-3 allow u to capture the enter desktop as a PNG file on your desktop.
2.Command-Control-Shift-3 help you to copy the enter desktop screenshot placed on clipboard to paste into another program.
3. Command-Shift-4 allow you to capture screenshot of selected area.A cross-hair cursor will appear and you can click and drag to select the area you wish to capture.
4.To capture a specific application window, press Command-Shift-4, then press the Spacebar. The cursor will change to a camera, and you can move it around the screen. As you move the cursor over an application window, the window will be highlighted. The entire window does not need to be visible for you to capture it. When you have the cursor over a window you want to capture, just click the mouse button and the screen shot will be saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
5. Add Control to the two shortcuts above to place the screen shot on the clipboard instead of saving it to the desktop.
6. Another method for capturing screen shots in Mac OS X is by using the bundled Apple utility, Grab, located in the Applications > Utilities folder. Grab is useful if you need to include a cursor or a menu in your screen shot, or if you want to save your screen shot to TIFF format. To include a cursor, first go to Grab Preferences and select the cursor icon you wish to have in your screen shot. To capture the screen with Grab, run Grab, then choose of the capture modes from the “Capture” menu: Selection, Window, Screen, Timed Screen.
7. When you choose the Selection mode in Grab, you can capture a specific region of the screen by dragging around it. Grab will display a tooltip showing the size of the region you have selected and the screen shot will open in a window when you release the mouse button. The cursor will not be included.
8. When you choose the Window mode in Grab, an instruction window will appear asking you to select the window you wish to capture, then click the “Choose Window” button. When you click the button, the instructions will disappear and the window you click ill be captured, including the mouse cursor at the position where you click (if a cursor was selected in Preferences).
9. When you choose the Screen mode in Grab, an instruction window will appear asking you to click the screen when you are ready to capture. The mouse cursor will be included in your screen shot at the position where you click (if a cursor was selected in Preferences).
10. When you choose the Timed Screen mode in Grab, an instruction window will appear, allowing you to prepare your screen for capture. When you are ready, press the “Start Timer” button and you will have ten seconds before the screen is captured. This allows you to open menus and sub-menus, if necessary. After ten seconds the entire screen will be captured. The mouse cursor will be included in your screen shot if a cursor was selected in Preferences.

Add a System Framework in iphone sdk project

To add a system framework like OpenAl.framework in your project follow the steps:
1. Go to Project menu->Add to project->now select framework.
2. framework path is:
System->developer->platform->iPhone Simulator->developer->SDKs-> iPhoneSimulator 2.2 sdk->System->Library->Frameworks
3. select OpenAL.framework and click Add button
4. again click Add button to add the framework in your project.

How set mod-rewrite on for your project in mac

Today while start working in an existing project which actually developed in windows, its all links are not working. So, first I have to set virtual host in leopard and place .htaccess file in my project root public_html folder. Then try to browse through all image buttons, but it didn’t work. We check mod-rewrite option, it didn’t works for our project. So I have to add following lines into /etc/httpd.conf file:

<Directory “/Applications/XAMPP/xamppfiles/htdocs/myproject.com/public_html”>

Options FollowSymLinks
AllowOverride All
#XAMPP
#Order deny,allow
#Deny from all

</Directory>

here myproject.com is my project folder name. Now I can browse again through all buttons.

Places Where Submit iPhone App Free

You can submit your iPhone App with no cost in following sites:
http://iphoneapplicationlist.com
http://www.appsafari.com
http://www.apptheater.com
http://toucharcade.com
http://www.iphoneblog.de
http://www.pocketgamer.co.uk
http://www.appcraver.com
http://www.appsundco.de
http://appbeacon.com
http://www.gamestooge.com
http://www.filedownloadfull.com
http://newmobiletech.com
http://www.appstoreapps.com
http://apptester.de
http://www.apptism.com
http://www.fishlabs.net

It increase your marketing as well as downloads.

sqlite3 Framework path for iPhone

In leopard 10.5 while u have to work with sqlite3 database u need to add the framework library to ur iPhone project. The framework path for libSqlite3.0 dylib is:
System->developer->platform->iPhone Simulator->developer->SDKs-> iPhoneSimulator 2.2 sdk->user->lib->

Configure Mozilla Firefox for Bengali Font

1.Open mozila firefox browser
2.From Tools menu, select Options.
3.From this Options window, click on Contents.
4. Click on Advanced button in Fonts & Colors section.

5. Click on the drop down list for option Fonts For. Select Bengali from this list.
6. Complete all the option fields as in the following image (you may choose your any favourite Bangla font) and then click on OK.

Now your configuration complete.