[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Getting all the values between empty elements

Subject: RE: Getting all the values between empty elements
From: "Kyle Partridge" <kpartridge@xxxxxxxxxxxx>
Date: Mon, 5 Jan 2004 17:09:29 -0500
xsl limit
Err...you were right - way too optimistic of me.

I apologize!  I see what you are getting at with this solution, but I
gave far too little information, I'm afraid...and I can't seem to
translate what you've suggested into an application that will work for
my situation.

Here's a bit more information (that I am quite sure everyone is sick of
by now, but I can't quite get to the end of it):

XML:
<p style="Normal" tabs="0.2 1.2 2.7">
<tab/>A Few<tab/>Lime <c val="#0f0">Green</c><tab/>Octopii<br/>
<tab/>Two<tab/>Red<tab/>Sharks<br/>
<tab/><tab/><tab/>Or something far more sinister?<br/>
</p>

With some help from Ken and Andreas, and some of my own flailing about,
I came up with this XSL to do the "rows" of a table to format this:

<xsl:template match="ws:br" mode="rowcreate">
	<xsl:variable name="current-row" select="position()"/>
	<xsl:variable name="number-of-cells"
select="count(preceding-sibling::ws:tab) div $current-row"/>
	<xsl:variable name="lower-limit" select="($current-row - 1) *
$number-of-cells"/>
	<xsl:variable name="upper-limit" select="$current-row *
$number-of-cells"/>
	<fo:table-row>
		<xsl:for-each select="preceding-sibling::ws:tab">
			<xsl:variable name="tab-number"
select="position()"/>
			<xsl:if test="$tab-number>$lower-limit and
$tab-number&lt;=$upper-limit">
				<xsl:choose>
					<xsl:when
test="./preceding-sibling::node()[1][name()='br' or name()='tab']">
						<fo:table-cell>
	
<fo:block>&#160;</fo:block>
						</fo:table-cell>
					</xsl:when>
					<xsl:otherwise>
						<fo:table-cell>
							<fo:block>
	
<xsl:value-of select="preceding-sibling::text()[1]"/>			
							</fo:block>
						</fo:table-cell>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
		</xsl:for-each>
		<fo:table-cell>
			<fo:block>
				<xsl:value-of
select="preceding-sibling::text()[1]"/>
			</fo:block>
		</fo:table-cell>	
	</fo:table-row>
</xsl:template>	

What I want to do is replace the <xsl:value-of
select="preceding-sibling::text()[1]"/> with an apply-templates on
everything between either a tab and another tab, or a br and a tab.  I
can't just loop through the preceding(or following) sibling tabs, or the
child of p tabs, because when I go through each "set" of tab-siblings, I
have to do different treatments to ensure that <br/> tags will end a
row.  That's what all that silly lower-limit and upper-limit business is
about...

Thanks,
KP




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.