Wednesday, March 23, 2011

xslt simple tutorial

In order to illustrate how XSLT can work on XML, follow the example below.

  1. Create one file called "test.xml" in notepad and paste the content below.
  2. <?xml version="1.0" encoding="ISO-8859-1"?> <catalog>   <cd>     <title>Empire Burlesque</title>     <artist>Bob Dylan</artist>     <country>USA</country>     <company>Columbia</company>     <price>10.90</price>     <year>1985</year>   </cd> </catalog>
  3. Create a file called "display.xsl"
  4. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/">   <html>   <body>   <h2>My CD Collection</h2>   <table border="1">     <tr bgcolor="#9acd32">       <th>Title</th>       <th>Artist</th>     </tr>     <xsl:for-each select="catalog/cd">     <tr>       <td><xsl:value-of select="title"/></td>       <td><xsl:value-of select="artist"/></td>     </tr>     </xsl:for-each>   </table>   </body>   </html> </xsl:template> </xsl:stylesheet>

  5. Try to open test.xml and you will get the normal xml display
  6. Try to add following line into your xml
  7. <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="display.xsl"?> <catalog>   <cd>     <title>Empire Burlesque</title>     <artist>Bob Dylan

  8. Try to double click on your xml file again and its been transform

Tuesday, March 22, 2011

Progressive sum

I have been struggling with progressive sum after reading some other people code who is using cursor to achieve this.

Before I provide the code, let me explain what is progressive sum. Progressive sum is usually used by accounting where you need to add or minus the value base on row level rather than give one value of sum. Below would be the example

IDinsertDatevalueProgressive_sum
12011-03-23 12:39:58.3172525
22011-03-23 12:39:58.3201540
32011-03-23 12:39:58.320-1525

As you can see on the row 1, we insert a value 25 and the progressive sum is 24. Once we insert value 15, the system automatically added 25+15 = 40.

Below would be the sample code that I use to produce the result above

create table #tmpAccounting
(
  ID int identity,
  insertDate datetime default getdate(),
  value float
)
insert into #tmpAccounting (value) values (25)
insert into #tmpAccounting (value) values (15)
insert into #tmpAccounting (value) values (-15)

select *, (select sum(value) from #tmpAccounting where insertDate<=a.insertDate and ID<=a.ID) as Progressive_Sum  from #tmpAccounting a order by ID

drop table #tmpAccounting

Friday, January 14, 2011

How to undo changes in tfs for codeplex?

I was struggling when I need to undo lock by another developer who leave the team but check out every single line of my code.

Due to this, I send few hours to find ways to undo the lock. So to do this, I need 2 things.

1) User Name (very simple...since I already have this)
2) Workspace name (damn... I need to call the developer to get this)

For the 2nd item, it is kinda hard to get since the developer is living on the other part of the world. So to do this, I found out that there is one command we can use to find out.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC> tf workspaces /owner:[username] /s:https://tfs.codeplex.com/tfs/tfs20

With the command above you will get the output like below...

Collection: tfs.codeplex.com\TFS20
Workspace Owner       Computer Comment
--------- ----------- -------- ------------------------------------------------
(clipped)

From this, I manage to get the workspace name (which is the first field) from the listing.

Then I just need to type another command to undo everything

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>tf undo /workspace:[workspace name];[user id] /recursive $/simweb /s:https://tfs.codeplex.com/tfs/tfs20

Then its done!

Monday, November 8, 2010

Some piece of XSLT information that you might need to be successful

- Put special character in the XSLT or XML

< ==> (<)

& ==> (&)
> ==> (>)
" ==> (")
' ==> (')

Wednesday, October 27, 2010

RosettaNet PIP 3A1 release

After spending days to understand and try to make PIP 3A1 as workable class, i manage to release the first version to codeplex.

Hopefully this release will be helpful to those who are seeking for the same PIP as me.

http://rosettanetpip.codeplex.com/

Tuesday, October 19, 2010

VB.NET: How to put description to your function/class/enum during Intellisense

I struggle for hours on how to get description to my enum and class so they can be more meaningful when I'm assigning the value to them. After spending for hours searching, I manage to found it!!!!

Below would be the sample on what is the effect i'm looking for


Below would be my code on how I do it...

--- Code from my enum ---

''' Code identifying the type of pricing available for a product.
Public Enum PricingTypeCode
''' Authorized Cost and Resale.
ACR
''' Authorized Cost - The negotiated cost agreed upon between the supplier and distributor at the time the “debit?is authorized.
ACS
''' Authorized cost.
ACT
''' Any available.
ANY
''' Authorized resale.
ARS
''' Average Selling Price - Manufacturer
ASP
''' Budgetary Price Amount.
BPA
''' Broken Purchase Price.
BPP
''' Book-Ship.
BSH
''' Catalog price - Book (the supplier’s published cost at the time of transaction) or Published Price.


I hope this tutorial will help others

Monday, September 6, 2010

How to load web application code from TFS?

I have been teaching quite a number of developer on how to get their source code download properly into the development environment. I hope this step will help others along the ways.

How to open web project in TFS?

1. Go to team explorer and double click on Source Control
2. Go to the folder that contain your .sln file
3. Double click on the SLN
4. If you never download your code before from TFS, it will ask you for the path to save in. Please save the code in your "My Document>Visual Studio 2008 projects>..."
5. Once the code is download, you will be prompt that you might need to create a web application in your IIS. The message sound like "The local IIS URL: http://localhost/xxx specified for Web Project XXX...". Don't click Yes first, go to IIS
6. Under the IIS, find if there is same virtual directory existed. If it is, delete it. If not, just skip and move on to the next step.
7. Click "Yes" on the earlier message on creating web application.
8. Go to IIS again, and refresh it
9. Right click on the new folder which belong to your application and select properties
10. Go to Directory Security Tab
11. Click Edit under Authentication and access control
12. Ensure the Integrated Windows authentication is checked and copy down the user name use by the web application
13. Go to your physical folder which your source code located and right click on it.
14. Click on Security Tab and click Add
15. Paste the username that you copied earlier and click Ok
16. Give full permission to the user.