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.

Friday, May 17, 2013

Replace a schema in a map: the easy way

We had a little problem on the first day in production of an EDI project, when our partner says they have to send their orders in EFACT_D96A_ORDERS_EAN008, instead of the EFACT_D93A_ORDERS_EAN007 we tested for months. Not a big stress. Those schemas are similar, so the change was easy.

To redo a map like this one and properly test it in the same day, was impossible. But the task was simplified in the fastest way. No XSLT knowledge needed, just basic XML and logic.

Supposing the change is in the input

1. Add the new schema or reference to the project.

2. Open the btm as xml.

3. Find and replace all references
3.1. Source Tree Root Node and Location

<SrcTree RootNode_Name="EFACT_D93A_ORDERS_EAN007">
<Reference Location="*.EFACT_D93A_ORDERS_EAN007" />
3.2. Some on the Link elements (LinkFrom attribute).

<Link LinkID="9" LinkFrom="10" LinkTo="/*[local-name()='<Schema>']/*[local-name()='ORDERS01']/*[local-name()='E1EDK03']/*[local-name()='DATAHEADERREC']/*[local-name()='DOCNUM']" Label="" />
        <Link LinkID="10" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='EFACT_D93A_ORDERS_EAN007']/*[local-name()='DTM']/*[local-name()='C507']/*[local-name()='C50702']" LinkTo="9" Label="" />
        <Link LinkID="11" LinkFrom="/*[local-name()='<Schema>']/*[local-name()='EFACT_D93A_ORDERS_EAN007']/*[local-name()='DTM']" LinkTo="11" Label="" />

4. Close the xml view and open the same .btm with the regular view.

4.1. If no Map Loading Errors popped up, it’s done.
4.2. Otherwise, keep following the procedure.

5. Copy all the errors (no Ctrl+A here, just the old mouse dragging).

(1) Link from Source Tree Node with XPath: '/*[local-name()='']/*[local-name()='EFACT_D96A_ORDERS_EAN008']/*[local-name()='LINLoop1']/*[local-name()='QTY_3']/*[local-name()='C186_3']/*[local-name()='C18601']' to Equal functoid (with FunctoidID: 30).

6. Close the errors screen but DO NOT save the map.

7. Locate the missing field and take note of the correct path
In this case there was no EFACT_D96A_ORDERS_EAN008/LINLoop1/QTY_3/C186_3/C18601 , but instead, EFACT_D96A_ORDERS_EAN008/LINLoop1/QTY_2/C186_2/C18601

8. Close the map (don’t save!) and open again with the xml view.

9. Replace those fields. [local -name()='QTY_3']/*[local-name()='C186_3'] to [local-name()='QTY_2']/*[local-name()='C186_2']. In case of doubt, use the FunctoidId or any additional info from the errors screen to locate the Link Id.

10. Repeat from step 4 until all the errors are gone.

Changes in Destination schema are in TrgTree instead of SrcTree, and LinkTo instead of LinkFrom.

Please note that this is only an advanced starting point. If the schema was replaced, probably it was because the previous one no longer supported the information needed. It’s very likely new fields are filled and some others have changed, including the ones used within the map. A new batch of tests will show it very quickly.

Extra: Two orchestrations sharing a receive port

If they enter by the same port, use the Message property to receive only one of them.
If they arrive by Direct Binding –independently of the port, from the MessageBox - use the Filter Expression.

Be careful with:

  • Typename
    Don’t give the same name to both. Not only it is unauthorized, but also is the name by which the orchestrations will be known after deployment and so should be different for whoever is managing.
  • Ports types
    The Orchestration 2 will try to create a port type that already exists. Delete the Operation on every port and configure to use the type from Orchestration 1. If the input message is different (source schema changed) the receive port will have a different type. The same goes for the output message (when the target schema changed) at the send port.
  • Tuesday, February 26, 2013

    Code. Just Code.

    Fabulous work of promotion to the programming science/art.

    Sunday, December 2, 2012

    Putting rhythm into the Quick Sort Algorithm

    Trouble explaning QSA to young students? Or maybe to understand it yourself? Here it is by an Hungarian dance company.

    Tuesday, March 27, 2012

    Copy name and value with XSLT

    I run across a situation where I had to map a huge list of sibling nodes. I was required to send tuples of name (in upper case) and value. If they were few, I would use a Table Looping like always, but this time it was a lot of fields and I was feeling lazy. Here is the solution.

    <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
    <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

                <xsl:for-each select="//Data/item/*">
                      <xsl:element name="ns0:GenericDataContainerEntry">
                            <xsl:element name="ns0:GenericDataContainerEntryIndex">
                                  <xsl:attribute name="value">
                                        <xsl:value-of select="./text()" />
                                  <xsl:attribute name="name">
                                        <xsl:value-of select="translate(name(.),$smallcase,$uppercase)" />

    Do to all nodes

    <xsl:for-each select="//Data/item/*">

    Copy value

    <xsl:value-of select="./text()" />

    Copy name

    <xsl:value-of select="name(.)" />

    Copy name in upper case in XSLT 1.0 (found it here)

    <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
    <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
    <xsl:value-of select="translate(name(.),$smallcase,$uppercase)" />

    Monday, October 31, 2011

    MSSQL - Saving Changes in Not Permitted

    Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.

    When getting this error in SQL Server Management Studio 2008, be aware that when you redesign a table is a way that affects it's structure, the action requires the table to be recreated. By default the Database Management Studio will not allow you to recreate it, therefore no changes allowed.

    The solution is simple.
    1) Go to Tools -> Options
    2) Select the tab Designers and inside of it Tables and designers
    3) Uncheck Prevent saving changes that require table re-creation
    4) Save
    SQL Saving Changes Is Not Permitted

    This configuration is very obvious, but the path to it is rather obscure so it is here for future reference.

    Friday, August 26, 2011

    401 - Unhautorized (Invalid Credentials in IE)

    We started having problems with Integrated Authentication in our Outsystems solution. We made tests for two months with a dozen of different users and all main browsers (IE8 and 9, Firefox 5 and 6, Chrome 13) with absolutelly no problems of that type.

    This is a technology I strongly recommend for it's speed, potential and ease of use, so such a basic problem days before going to the production environment was totally unexpected.


    The Integrated Authentication with Active Directory wasn't working. It usually enters automatically in IE and requests for AD login in other browsers. This time Mozilla and Chrome were working as usual, but IE was requesting credentials and giving error 401 - Unhautorized validating them.


    We debugged the application from start to finish not finding a reason for it. The solution was found in a forum, not about Outsystems, but about IIS7 (LINK).

    The answer given by jay-dubb was:
    To whoever this may help, this saved my life...

    IIS 7 was difficult for figuring out why i was getting the 401 - Unauthorized: Access is denied due to invalid credentials... until i did this...

    1.) Open iis and select the website that is causing the 401

    2.) Open the "Authentication" property under the "IIS" header

    3.) Click the "Windows Authentication" item and click "Providers"

    4.) For me the issue was that Negotiate was above NTLM. I assume that there was some kind of handshake going on behind the scenes, but i was never really authenticated. I moved the NTLM to the top most spot, and BAM that fixed it.

    To us it worked like a charm, proving once again that the problem is never in Outsystems.

    Thursday, March 24, 2011

    Basics - How to confirm a Biztalk update

    Here are the version numbers of current Biztalk 2006 R2 as seen at Microsoft.

    BizTalk Server 2006 R23.6.1404.0
    BizTalk Server 2006 R2 SP13.6.2149.10January 27th, 2010
    Cumulative Update 1 (CU1)3.6.2210.12April 12th, 2010
    Cumulative Update 2 (CU2)3.6.2217.12June 24th, 2010
    Cumulative Update 3 (CU3)3.6.2224.12August 30th, 2010

    For other Biztalk versions you can explore another Microsoft Link.

    We made an update on Biztalk to CU3 and the version seen at About was still 3.6.2149.10, referring to the SP1.

    To know the specific add-ons like CU's, and hotfixes, the only place to go is Add and Remove Programs. Just remember to mark the Show Updates. checkbox.