reading lines of file

Home Page Forums BizTalk 2004 – BizTalk 2010 reading lines of file

Viewing 1 reply thread
  • Author
    Posts
    • #15047

      Well, actually i’m mentally blocked… After read the header of the flat, I have to read each row of the body file, and check it (the format fields)that each row is correct or wrong. Then, i have to build two new files: one of them, only with the correct rows and the other file, only with the wrong rows…
      What I did, was to include a Catch exception, but at the first mistake, catch the exception and it takes me to the other part of the program, and didn’t read any more rows ..
      Please, any Idea?
      Thanks!!

    • #15048

      but, if I Have to create a new map, how I can aggregate this code??
      Or I have to aggregate this code in a form in the orchestration?

      and ,if for example, my file only contains a Id Field in the header, a Name field in the body and a IdEnd field in the end of the field.. how it would be the xslt?

      Thanks!! 😆

      • #15049

        Exists other way?? Can we use to do this an ReceivePipeline?
        Thanks

        • #15050

          Thanks prodigy… Do you know any example project, to download and have a guide?… I’m new in biztalk!

          • #15051

            One way of doing this is using a map.
            You can create a custom Xslt based on a Schematron pattern, that will iterate thru the records creating an output for each error discovered.

            Here is a brief example.
            The test conditon can be virtually anything including script

            [code:1:33c95ab219]
            <xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"
            xmlns:msxsl=\"urn:schemas-microsoft-com:xslt\"
            xmlns:var=\"http://schemas.microsoft.com/BizTalk/2003/var\"
            exclude-result-prefixes=\"msxsl var s0 userCSharp\"
            version=\"1.0\" xmlns:ns0=\"http://Supplier.Invoice.InvoiceValidationReport\"
            xmlns:s0=\"urn:schemas-custom-com:Invoice\"
            xmlns:userCSharp=\"http://schemas.microsoft.com/BizTalk/2003/userCSharp\">
            <xsl:output omit-xml-declaration=\"yes\" version=\"1.0\" method=\"xml\" />
            <xsl:template match=\"/\">
            <xsl:apply-templates select=\"/s0:document\" />
            </xsl:template>
            <xsl:template match=\"/s0:invoice\">
            <ns0:InvoiceValidationReport>
            <xsl:for-each select=\"line\">
            <xsl:call-template name=\"Validate\"/>
            </xsl:for-each>
            <xsl:variable name=\"var:errors\" select=\"userCSharp:GetErrorCount()\"/>
            <errorCount><xsl:value-of select=\"$var:errors\"/></errorCount>
            </ns0:InvoiceValidationReport>
            </xsl:template>
            <xsl:template name=\"Validate\">
            <xsl:choose>
            <xsl:when test=\"s0:lineNumber and s0:lineNumber/text()\" />
            <xsl:otherwise>
            <error>
            <xpath>/invoice/invoiceNumber</xpath>
            <description>Missing Invoice Number</description>
            </error>
            <xsl:variable name=\"var:e1\" select=\"userCSharp:IncrementErrorCount()\"/>
            </xsl:otherwise>
            </xsl:choose>
            </xsl:template>
            <msxsl:script language=\"C#\" implements-prefix=\"userCSharp\"><![CDATA[
            public int errorCount = 0;
            public int IncrementErrorCount()
            {
            return ++errorCount;
            }
            public int GetErrorCount()
            {
            return errorCount;
            }]]></msxsl:script>
            </xsl:stylesheet>
            [/code:1:33c95ab219]

            You can use a Decide shape after the map to check the errorCount, if greater than zero take action with the map output, otherwise continue with the original document.

            • #15052

              first thing it came up to my head:
              Use a filed as a \”flag\”, then on the orchestrations test the field (don’t forget to promote the field), and give it different sendports!

              • #15053

                why dont you parse the file in and have a map go through each line, evaluate whether or not its correct and map it accordingly.

                use a script functiod that returns a bool and feed it into a value map shape. now feed this line as well to the value map shape. be sure to take the bool output of your script to the node itself for the good lines and invert it to the bad lines.. this will supress the empty nodes.

                • #15054

                  here is an example by Stephen Kaufman the illustrates conditional mapping. this should give you a general idea that should steer you in the right direction. of course, you would have logic instead of a simple \”exists\” or \”= ‘United States’\” but youll get the idea.

                  If you still cant get the solution working, send me a pair of files and I’ll whip you something up.

                  Welcome to our world lucky027 😀

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.