XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Sharry StowellSubject: XSL Looping
Author: Sharry Stowell
Date: 28 Mar 2006 07:23 PM
Hi, I want to loop through a string. Say I have a variable with 15 characters in length.

var1 = ab-defghijklmno

I want to output it in a table:

<table>
<tr>
<td>a</td>
<td>b</td>
<td bgcolor="black">&nbsp;</td>
<td>e</td>
etc

I want it to loop through the string, if it comes across a '-' character write a different td output. Sounds simple, but I cannot do it! Any help much appreciated! Thanks


DocumentdisplayGrid.xsl
XSL File

Unknownstage1.xml
XML file

Postnext
Minollo I.Subject: XSL Looping
Author: Minollo I.
Date: 28 Mar 2006 08:32 PM
Something that may be useful is...

<xsl:template match="/">
<table>
<tr>
<xsl:call-template name="explodeString">
<xsl:with-param name="txt" select="'ab-defg'"/>
</xsl:call-template>
</tr>
</table>
</xsl:template>

<xsl:template name="explodeString">
<xsl:param name="txt"/>
<xsl:param name="pos" select="1"/>

<xsl:choose>
<xsl:when test="substring($txt, $pos, 1) = '-'">
<td>something special</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="substring($txt, $pos, 1)"/>
</td>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$pos &lt; string-length($txt)">
<xsl:call-template name="explodeString">
<xsl:with-param name="txt" select="$txt"/>
<xsl:with-param name="pos" select="$pos+1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

Postnext
Sharry StowellSubject: XSL Looping
Author: Sharry Stowell
Date: 29 Mar 2006 08:09 AM
Helpful as always, Minollo, thanks :)

Postnext
Sharry StowellSubject: XSL Looping
Author: Sharry Stowell
Date: 30 Mar 2006 02:35 PM
Using the same files above, esp .xml

I want to output a number in the top left hand corner (like a crossword), eg,
1 Across (4) = 'Read me', refers to a grid location where a little 1 would show in that location:

SUPPOSED TO BE PART OF TOP-LEFT OF CROSSWORD
------------------------------------------------------
1 | | | |\\\\\\\|2 |
| | | |\\\\\\\| |
B | O | O | K |\\\\\\\| |
| | | |\\\\\\\| |
-------------------------------------------------------

See where the 1 & 2 are. I need to create them, I have a 15 by 15 grid, each lines is displayed by a different rowVariable (created by substringing a 225 length allAnswer variable every 15 characters).

Is there XPATH/XSL expressions, that would generate these please?

Any help would be much appreciated, thank you.

Postnext
Sharry StowellSubject: XSL Looping
Author: Sharry Stowell
Date: 30 Mar 2006 02:41 PM
Messed up a bit, please see here:
http://img77.imageshack.us/img77/1817/crosswordoutput3fq.jpg

Posttop
Minollo I.Subject: XSL Looping
Author: Minollo I.
Date: 30 Mar 2006 02:44 PM
Sorry; general XSLT questions are better asked (and answered) on the xsl-list at mulberrytech.com

Thanks,
Minollo

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.