Home Page › Forums › BizTalk 2004 – BizTalk 2010 › reading lines of file
- This topic has 7 replies, 1 voice, and was last updated 9 years, 5 months ago by
community-content.
-
AuthorPosts
-
-
July 15, 2006 at 11:11 AM #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!! -
July 21, 2006 at 5:10 PM #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!! 😆
-
July 24, 2006 at 9:46 AM #15049
Exists other way?? Can we use to do this an ReceivePipeline?
Thanks-
July 24, 2006 at 9:11 PM #15050
Thanks prodigy… Do you know any example project, to download and have a guide?… I’m new in biztalk!
-
July 17, 2006 at 9:09 AM #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.
-
July 24, 2006 at 9:46 AM #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!-
July 24, 2006 at 8:59 PM #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.
-
July 24, 2006 at 10:50 PM #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 😀
-
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.