XSLTGeneral questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I'm having some trouble finding the correct syntax for a loop I'm trying using msxsl command line processor to parse an xml file. I have a date tag that gives me a substring that will vary in length from 8 - 10 characters depending on the day and month ( example: 3/3/2006 or 12/12/2006) I want my substring "value-of select" below to look at the total length of the substring( whether it be 8,9 or 10) and return only the last 2 characters for my date. Any suggestions about how to do this would be appreciated.
I can't relate the description of the problem to your code fragment. What exactly is your input and your desired output?
In general, if you're dealing with input that has variable length components separated by delimiter characters, you want to process it using substring-before and substring-after, not using substring, which is designed for extracting fixed-length fields at a fixed position.
My input date format is 3/3/2006 and my output format needs to be 060303 or for a two digit date input like 11/25/2006 it would need to be 061125. Basically for each date tag I need a loop that looks at the day,month,year and reorders it and drops each /. The loop structure I posted before worked for a date format like 01Sep06 and I was trying to figure out how to incorporate that for the new input tags with variable month sizes.
In 1.0, You just need to pick out the components of the date using substring-before and substring-after, e.g. the second component is substring-before(substring-after($in, '/'), '/'). Then you can use format-number to add a leading zero, and concat() to put the three parts together in the right order.