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

Re: Formatting issues

Subject: Re: Formatting issues
From: ms <mina_hurray@xxxxxxxxx>
Date: Tue, 26 Dec 2006 06:18:20 -0800 (PST)
Re:  Formatting issues
Hi:

Thank you for your help so far. I forgot to mention
that I use xslt 1.0, I am not sure if we can use for
statements in 1.0

Here are my examples:

Input XML:

<root>
	<level1>
		<text>
			<para>This has values high and steep</para>
		</text>
		<locn>
			<cond1>high</cond1>
			<cond2>steep</cond2>
		</locn>
		<level2>
			<text>
				<para>This has values high and deep</para>
			</text>
			<locn>
				<cond1>high</cond1>
				<cond2>deep</cond2>
			</locn>
		</level2>
	</level1>
	<level1>
		<text>
			<para>This has values high and low</para>
		</text>
		<locn>
			<cond1>high</cond1>
			<cond2>low</cond2>
		</locn>
	</level1>
	<level1>
		<text>
			<para>This has values high and steep</para>
		</text>
		<locn>
			<cond1>			high</cond1>
			<cond2>steep</cond2>
		</locn>
		<level2>
			<text>
				<para>This has values high and steep</para>
			</text>
			<locn>
				<cond1>high</cond1>
				<cond2>steep</cond2>
			</locn>
		</level2>
	</level1>
</root>


XSLT for level1:

<xsl:template match="level1">
	<xsl:choose>
		<xsl:when test=".//locn">
			<xsl:if test=".//locn/cond1=$cond1 and
.//locn/cond2=$cond2">
				<fo:list-block space-before="6pt"
space-before.conditionality="retain">
					<fo:list-item>
						<fo:list-item-label end-indent="label-end()">
							<fo:block>
								<xsl:number format="1" from="level1"/>
							</fo:block>
						</fo:list-item-label>
						<fo:list-item-body start-indent="body-start()"
end-indent="0pt">
							<fo:block>
								<xsl:apply-templates/>
							</fo:block>
						</fo:list-item-body>
					</fo:list-item>
				</fo:list-block>
			</xsl:if>
		</xsl:when>
	</xsl:choose>
</xsl:template>

This template repeats for level2...6

$cond1 and $cond2 are being passed thru the xslt for
testing purposes and have been set to high and steep
respectively for testing.

So given $cond1=high and $cond2=steep

The output when this XSLT is applied to the XML ,
should be:

1. This has values high and steep
2. This has values high and steep.
    A. This has values high and steep.

But what I am getting is this:

1. This has values high and steep
1. This has values high and steep.
    A. This has values high and steep.

Please let me know how this ca be resolved.

--- Abel Braaksma <abel.online@xxxxxxxxx> wrote:

> ms wrote:
> > Level1 - 1,2,3 etc
> > Level2 - A, B, C
> > Level3 - i,ii,..
> > Level4 - (1), (2)
> > Level5 - (a), (b)
> > Level6 - (i), (ii)
> >   
> 
> Aha. Well, just add more templates to my base
> template.
> 
> > The hierarchy for levels is that level 1 is the
> parent
> > for level2, level2 is he parent for level3 and so
> on.
> > i.e.
> >
> > [...]
> >
> > Now in an XML , there can be any number of these
> > levels, and I have a logic to filter these levels
> > based on certain conditions.
> >   
> 
> I see. So that part is working. Send your XSLT for
> where it is not 
> working. Make the smallest possible example that
> does not work, and add 
> the input, too. Also, add an example of what the
> output is that you expect.
> 
> > I tried <xsl:number from="level1" format="1"/>
> > But that only numbers all levels with 1 and does
> not
> > increment them sequentially. 
> >   
> 
> Indeed. In your <xsl:template> where you match for
> "level1", add a 
> variable with one <xsl:number /> instruction in it.
> That's your counter 
> (see my example).
> 
> > This is my problem. How do I write the XSLT to
> > basically check if previous levels have satisfied
> the
> > filtering condition
> 
> This is what my XSLT is about. You can use it for
> that. Though I assume 
> you will have to use the your own XPath expressions
> in the matches.
> 
> >  and if they have, include them for
> > counting, else remove them and count only those
> levels
> > that satisfy the condition and count sequentially.
> >   
> 
> Which is what it does, too ;)
> Your conditions will likely be different, though.
> 
> Please send what you've got (minimized to your
> problem domain).
> 
> Cheers,
> -- Abel
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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-2007 All Rights Reserved.