Friday, October 24, 2014

When Women Stopped Coding

This article alerts that women may have stopped coding because the gaming/film industry pushed the personal computers to males.

Having studied in schools where girls were around 60% of the total students, at the university I got the shock of seeing that girls studying Computer Sciences represented around 10% of the course students while in some other courses they were 95%. As a consequence, most of the people I end up working with are men.

Come on, girls! Don't let a stereotype beat you. This is the 21th century and everyone should be oblivious of genre discrimination by now.

Thursday, September 25, 2014

E-Book "BizTalk Mapping Patterns & Best Practices" free at Biztalk360

If you're into Biztalk mapping, you need to check Sandro Pereira's book, "BizTalk Mapping Patterns & Best Practices".

In 350 pages (367, but you can skip the first 15), you can learn in detail several tricks of 12 mapping patterns that will help you to be more productive (only if you want, of course).

To download the book, you have to give a valid email.

Monday, January 20, 2014

How to remove trailing zeros when XSLT can't do it

We ran into a situation where we needed to search the document number in a database. To avoid misleads by leading zeros, we've always converted that string to numeric using number().

But suddenly, a huge number appeared... and XSLT was representing it in scientific notation.

What other ways can leading zeros desappear? In XSLT 2.0 we can say "remove all zeros at beginning"
replace( $value, '^0*', '' )

In XSLT 1.0 it takes more. We needed a recursive template to take down 0's one by one.

<xsl:template name="remove-leading-zeros">
<xsl:template name="remove-leading-zeros">
<xsl:template name="remove-leading-zeros">
<xsl:param name="value"></xsl:param>
</xsl:template><xsl:template name="remove-leading-zeros">
<xsl:template name="remove-leading-zeros">
    <xsl:when test="starts-with($value,'0')">
      <xsl:call-template name="remove-leading-zeros">
        <xsl:with-param name="value">select="substring-after($value,'0')"/></xsl:with-param></xsl:call-template>
      <xsl:value-of select="$value">
<xsl:template name="remove-leading-zeros">

<xsl:param name="value"><xsl:choose><xsl:when test="starts-with($value,'0')"><xsl:call-template name="remove-leading-zeros"><xsl:with-param br="" name="value"> </xsl:with-param></xsl:call-template> </xsl:when></xsl:choose></xsl:param><xsl:otherwise><xsl:value-of select="$value"></xsl:value-of></xsl:otherwise>
There is a smaller solution. It's not that easy to understand, but it works.Instead of replace we could use
translate($value, '0', '')
, but this would simply remove the 0's everywhere. Good, but not what we planned.

Use it like this to find the first non 0.
substring(translate($value, '0', ''), 1, 1)

We can't do a substring-after or we'd lose that first non-zero, but we can see what is before it.
substring-before($value, substring(translate($value, '0', ''), 1, 1))

Then, get what is after the leading 0's.
substring-after($var, substring-before($value, substring(translate($value, '0', ''), 1, 1)))

Not that bad.