[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Response to Wolfgang Laun, Michele R Combs and G K
At 2012-04-09 18:35 +0000, Peterson, Melanie S. wrote:
The input for the XML can be any number of triads of information. So for example, the input could be Ah, okay ... this is new. This definitely is easier to deal with using XSLT 2.0. So the first example needs to look like this: Okay, then ... I've got some XSLT 2.0 code below for you based on this new requirement. But the code above doesn't mesh with the code that you show next. As I said, based on your input, I've gotten closer. Here's what I have so far: Right away I see a problem: the handling of APName is *inside* of a <tr>. And you cannot have in your output a <tr> as a child of a <tr>. So your code above cannot be producing <tr> elements during the handling of APName. You have to handle APName outside of the <tr> so that APName can create the <tr> elements. I hope the example XSLT 2.0 code below helps. It is tokenizing the input string into pieces and then grouping the pieces into groups of three and creating one row for each group. . . . . . . . . Ken
Input value: "aaa;bbb;ccc" Processed output: <tr> <td valign="top" width="180"/> <td>aaa</td> <td>bbb</td> <td>ccc</td> </tr> Input value: "aaa;bbb;ccc;ddd;eee;fff" Processed output: <tr> <td valign="top" width="180"/> <td>aaa</td> <td>bbb</td> <td>ccc</td> </tr> <tr> <td valign="top" width="180"/> <td>ddd</td> <td>eee</td> <td>fff</td> </tr> Input value: "aaa;;ccc" Processed output: <tr> <td valign="top" width="180"/> <td>aaa</td> <td/> <td>ccc</td> </tr> t:\ftemp>type melanie.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="APName"> Input value: "<xsl:value-of select="."/>" Processed output: <!--create groups of three using the tokenized input--> <xsl:for-each-group select="tokenize(.,';')" group-by="( position() - 1 ) idiv 3"> <!--each group produces a row--> <tr> <td valign="top" width="180"></td> <!--the members of the group make up the remaining columns--> <xsl:for-each select="current-group()"> <td> <xsl:value-of select="."/> </td> </xsl:for-each> </tr> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> t:\ftemp>echo Done! Done! -- Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012 Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
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
|