Tuesday, June 27, 2006

Text Legibility: Using 120 DPI Fonts on High Resolution Displays

You have high-resolution monitor and hate this small fonts? This article will help you:
Using 120 DPI Fonts on High Resolution Displays

Interactive design: Fitts law

This great and fun-to-read article explains fundamental law of interactive UI design.

A Quiz designed to Give You Fitts
"Fitts' Law: The time to acquire a target is a function of the distance to and size of the target."
.....
"Microsofts general cluelessness has never been so amply displayed, however, as it is in Microsoft Visual Studio, which has a menu bar at the top of the screen with a one-pixel barrier between the screentop and the menu. Talk about snatching defeat from the jaws of victory."

Interactive design: Fitts law

This great and fun-to-read article explains fundamental law of interactive UI design.

A Quiz designed to Give You Fitts
"Fitts' Law: The time to acquire a target is a function of the distance to and size of the target."
.....
"Microsofts general cluelessness has never been so amply displayed, however, as it is in Microsoft Visual Studio, which has a menu bar at the top of the screen with a one-pixel barrier between the screentop and the menu. Talk about snatching defeat from the jaws of victory."

Tuesday, June 20, 2006

ASP.NET 2.0 Web site compilation and deployment options

Good article about ASP.NET 2.0 web site deployment options: both scripts and UI:
Precompiling the Site

This is the command you could use to pre-compile everything (this should all be entered on one line):
aspnet_compiler.exe -p c:\Projects\ASP.NET\TheBeerHouse\TBH_Web -v /TheBeerHouse c:\Deployment\TheBeerHouse

In the case of deploying to your own sites, it’s simpler to pre-compile only the source code files but not the markup files. To do this, just add the -u switch (which stands for updateable) to the command line, as follows:
aspnet_compiler.exe -p c:\Projects\ASP.NET\TheBeerHouse\TBH_Web -v /TheBeerHouse -u c:\Deployment\TheBeerHouse

Compile with fixed DLL names:
aspnet_compiler.exe -p c:\Projects\ASP.NET\TheBeerHouse\TBH_Web -v /TheBeerHouse -u -fixednames c:\Deployment\TheBeerHouse

Download Visual Studio 2005 Web Deployment Projects

Merge all ASP.NET DLLs into one:
C:\Program Files\MSBuild\Microsoft\WebDeployment\v8.0\aspnet_merge.exe c:\Deployment\TheBeerHouse

---
Keywords: ASP.NET 2.0, C#, VB.NET 2.0, WebForms, Web Forms, Deployment

Friday, June 02, 2006

XML -> CSV XSL Transformation

CSV - comma separated values format (supported by Excel).
Handling quotes in XML->>CSV XSLT
First trick is to save the " and "" inside a variable, second trick is to use a recursive template.


Handling quotes, commas and line-breaks in XML->>CSV XSLT

In a CSV file, if a field value contains a comma or a linefeed or a quote, then
it must be enclosed in quotes.
Also, if a field value contains quotes, then an extra quote must be inserted in front of each quote.



My implementation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
<xsl:for-each select="Table">
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column1"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column2"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column3"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>


<xsl:template name="DisplayCSV">
<xsl:param name="field"/>

<xsl:variable name="linefeed">
<xsl:text>&#10;</xsl:text>
</xsl:variable>

<xsl:choose>
<xsl:when test="contains( $field, '&quot;' )">
<!-- Field contains a quote. We must enclose this field in quotes,
and we must escape each of the quotes in the field value.
-->
<xsl:text>"</xsl:text>

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="normalize-space($field)"/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>

<xsl:text>"</xsl:text>
</xsl:when>

<xsl:when test="contains( $field, ',' ) or
contains( $field, $linefeed )" >
<!-- Field contains a comma and/or a linefeed.
We must enclose this field in quotes.
-->
<xsl:text>"</xsl:text>
<xsl:value-of select="normalize-space($field)" />
<xsl:text>"</xsl:text>
</xsl:when>

<xsl:otherwise>
<!-- No need to enclose this field in quotes.
-->
<xsl:value-of select="normalize-space($field)" />
</xsl:otherwise>

</xsl:choose>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

XML -> CSV -> HTML conversion

CSV - comma separated values format (supported by Excel).
Handling quotes in XML->>CSV XSLT
First trick is to save the " and "" inside a variable, second trick is to use a recursive template.


Handling quotes, commas and line-breaks in XML->>CSV XSLT

In a CSV file, if a field value contains a comma or a linefeed or a quote, then
it must be enclosed in quotes.
Also, if a field value contains quotes, then an extra quote must be inserted in front of each quote.



My implementation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
<xsl:for-each select="Table">
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column1"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column2"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="Column3"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>


<xsl:template name="DisplayCSV">
<xsl:param name="field"/>

<xsl:variable name="linefeed">
<xsl:text>&#10;</xsl:text>
</xsl:variable>

<xsl:choose>
<xsl:when test="contains( $field, '&quot;' )">
<!-- Field contains a quote. We must enclose this field in quotes,
and we must escape each of the quotes in the field value.
-->
<xsl:text>"</xsl:text>

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="normalize-space($field)"/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>

<xsl:text>"</xsl:text>
</xsl:when>

<xsl:when test="contains( $field, ',' ) or
contains( $field, $linefeed )" >
<!-- Field contains a comma and/or a linefeed.
We must enclose this field in quotes.
-->
<xsl:text>"</xsl:text>
<xsl:value-of select="normalize-space($field)" />
<xsl:text>"</xsl:text>
</xsl:when>

<xsl:otherwise>
<!-- No need to enclose this field in quotes.
-->
<xsl:value-of select="normalize-space($field)" />
</xsl:otherwise>

</xsl:choose>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
Handling quotes in XML->>CSV XSLT
First trick is to save the " and "" inside a variable, second trick is to use a recursive template.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />

<xsl:template match="/">

<xsl:apply-templates select="." mode="x"/>

</xsl:template>
<xsl:template match="text()" mode="x">

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>

<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="."/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>




Handling quotes, commas and line-breaks in XML->>CSV XSLT


The solutions presented so far assume that
the field values will not contain any commas,
linefeeds or quotes.

In a CSV file, if a field value contains
a comma or a linefeed or a quote, then
it must be enclosed in quotes.

Also, if a field value contains quotes,
then an extra quote must be inserted in
front of each quote.



My implementation:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/">
Alternate Agent Number,Previous Agent Alpha,Agency Head Office
<xsl:for-each select="ODBCDBConnect">
<xsl:for-each select="Table">
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="ALKALTNUM"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="ALKPRVAGTA"/>
</xsl:call-template>
<xsl:text>,</xsl:text>
<xsl:call-template name="DisplayCSV">
<xsl:with-param name="field" select="ADAGHD"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>


<xsl:template name="DisplayCSV">
<xsl:param name="field"/>

<xsl:variable name="linefeed">
<xsl:text>&#10;</xsl:text>
</xsl:variable>

<xsl:choose>
<xsl:when test="contains( $field, '&quot;' )">
<!-- Field contains a quote. We must enclose this field in quotes,
and we must escape each of the quotes in the field value.
-->
<xsl:text>"</xsl:text>

<xsl:variable name="apos">"</xsl:variable>
<xsl:variable name="aposapos">""</xsl:variable>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="normalize-space($field)"/>
<xsl:with-param name="substringIn" select="$apos"/>
<xsl:with-param name="substringOut" select="$aposapos"/>
</xsl:call-template>

<xsl:text>"</xsl:text>
</xsl:when>

<xsl:when test="contains( $field, ',' ) or
contains( $field, $linefeed )" >
<!-- Field contains a comma and/or a linefeed.
We must enclose this field in quotes.
-->
<xsl:text>"</xsl:text>
<xsl:value-of select="normalize-space($field)" />
<xsl:text>"</xsl:text>
</xsl:when>

<xsl:otherwise>
<!-- No need to enclose this field in quotes.
-->
<xsl:value-of select="normalize-space($field)" />
</xsl:otherwise>

</xsl:choose>
</xsl:template>

<xsl:template name="SubstringReplace">
<xsl:param name="stringIn"/>
<xsl:param name="substringIn"/>
<xsl:param name="substringOut"/>
<xsl:choose>
<xsl:when test="contains($stringIn,$substringIn)">
<xsl:value-of select="concat(substring-before($stringIn,$substringIn),$substringOut)"/>
<xsl:call-template name="SubstringReplace">
<xsl:with-param name="stringIn" select="substring-after($stringIn,$substringIn)"/>
<xsl:with-param name="substringIn" select="$substringIn"/>
<xsl:with-param name="substringOut" select="$substringOut"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$stringIn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

Followers

About Me

My photo
Email me: blog@postjobfree.com