[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: starts-with(preceding-sibling::line,8)
To try and clear some things up. The files are arriving as .txt, .rdb, .asc format. I use a vb com to split the (often) huge file into sections (250 lines for fixed width,25 lines for any delimited format, these numbers showed the fastest processing time through trial and error). then each section is stripped of it's delimiters and surrounded by <f> tags to create an array of fields and enclosed in <line> tags (in the case of delimited files) or simply surrounded by <line> tags in the case of fixed-width files. Then a root tag <Temp> is added to the section. Then the section is transformed using the appropriate xsl. This is where each <line> gets tested for its type. starts-with 5 becomes <Batch>, starts-with 6 becomes <Transaction>, etc. After endOfFile has been reached, all the sections are put together and the entire transformed file is processed. David was correct in that I was missing a closing ")" in the not() test and once I corrected this the test works. The problem now is that its catching the first occurrence of 5 that is NOT in position()=1 and returning an error whether the preceding line has an 8 or not. here is a shorter version of the section in the xsl where the test is performed: <xsl:template match="line"> <xsl:if test="starts-with(., 5)"> <xsl:if test="string-length(.)<94"> <xsl:call-template name="Error"> <xsl:with-param name="errType">Header</xsl:with-param> <xsl:with-param name="errLine"><xsl:value-of select="."/></xsl:with-param> <xsl:with-param name="errPos"><xsl:value-of select="position()"/></xsl:with-param> </xsl:call-template> </xsl:if> <xsl:if test="position()>1 and not(starts-with(preceding-sibling::line,8))"> <xsl:call-template name="Error"> <xsl:with-param name="errType">Header</xsl:with-param> <xsl:with-param name="errLine"><xsl:value-of select="."/></xsl:with-param> <xsl:with-param name="errPos"><xsl:value-of select="position()"/></xsl:with-param> </xsl:call-template> </xsl:if> <Header> <xsl:attribute name="serviceClass"><xsl:value-of select="substring( ., 2, 3 )"/></xsl:attribute> <xsl:attribute name="companyName"><xsl:value-of select="substring( ., 5, 16 )"/></xsl:attribute> ...... </Header> </xsl:if> ....... </xsl:template> I know that xsl processing order and document order are not necessarily the same, but if the file is such as: <Temp> <line>..</line> <line>..</line> <line>..</line> <line>..</line> ........ </Temp> wouldn't preceding or preceding-sibling be the correct choice? thanks again kb Keith Brooks Software Developer Global eTelecom Keith@xxxxxxxxxxxxxxxxxx -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Michael Kay Sent: Thursday, July 12, 2001 2:59 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: starts-with(preceding-sibling::line,8) Since the error message relates to a "batch" tag, and there aren't any <batch> tags in the pieces of XML source and stylesheet that you've shown us, it's reasonable to assume that the error is in a part that you haven't shown us. Are you trying to run this in the browser? If so, that's the worst possible debugging environment. Get your self a processor that you can run from the command line. Mike Kay Software AG > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Keith > Sent: 11 July 2001 23:06 > To: Xsl-List (E-mail 2) > Subject: starts-with(preceding-sibling::line,8) > > > Good day everyone, > I had to move some logic from a VB component into several 'dedicated' > stylesheets. These files are coming in fixed-with, comma > delemited,quoted-comma etc. > the one in question is fixed-width and the order of the lines MUST be: > starting characters- > 5, then any number of paired 6's and 7's followed by an 8 > example: > > 598e3983423 John Smith12334 PhoenixAZ55866 23423423 > 43545 345345345 > 632434890 other info > 723423 other info > 6...... > 7...... > 8234234324 .............. > then it starts with a 5 and continues > > I already call to an Error template with parameters of the > section of the > file (header,batch,transaction,trailer) and the contents of > the line(node) > itself for lines of length less than is required, using <xsl:message > terminate="yes"> to generate the parseError reason. > all "line" nodes are children of a "Temp" root node > Now I want to call the same Error template IF the current line node > starts-with 5 but the preceding line node does not start with an 8 > > <this is the part of the template select="line" > section, after I test for > the starts-with 5 character and after the test is performed > to assure the > proper line character length> > > <xsl:if test="position()>1 and > not(starts-with(preceding::line,8)">'of > course the first line won't have a closing line behind it > <xsl:call-template name="Error"> > <xsl:with-param name="errType">Header</xsl:with-param> > <xsl:with-param name="errLine"><xsl:value-of > select="."/></xsl:with-param> > </xsl:call-template> > </xsl:if> > > I can't seem to combine the starts-with and the preceding or > preceding-sibling functions to make it work right. I always > get a parserror > reason that the closing batch tag doesn't match the starting > header tag (or > something to that effect). This would be fine if there was > only one batch in > the file, however there can be thousands, so returning the > actual line and > section really helps troubleshooting the error. > > any help would be greatly appreciated. > thanks all > > > Keith Brooks > Software Developer > Global eTelecom > Keith@xxxxxxxxxxxxxxxxxx > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|