Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Formatting issues

From: ms <mina_hurray@--------->
To:
Date: 1/2/2007 5:52:00 PM
Hi:
 Thank you for all your help. 
Here is the sample XML:

<?xml version="1.0" encoding="UTF-8"?>
<?altova_xslfo E:\User Profiles\n26353\My
Documents\DigitalData\AMDS-0.6.3\Issues\Visit_Conditioning\test.xsl?>
<root>
	<test>
		<level1>
			<text>
				<para>This level should be displayed only if the
conditions are high and low.</para>
			</text>
			<locn>
				<cond1>high</cond1>
				<cond2>low</cond2>
			</locn>
			<level2>
				<text>
					<para>This level should be displayed only if the
conditions are high and deep.</para>
				</text>
				<locn>
					<cond1>high</cond1>
					<cond2>deep</cond2>
				</locn>
			</level2>
		</level1>
		<level1>
			<text>
				<para>This level should be displayed only if the
conditions are high and deep</para>
			</text>
			<locn>
				<cond1>high</cond1>
				<cond2>deep</cond2>
			</locn>
		</level1>
		<level1>
			<text>
				<para>This level should be displayed only if the
conditions are  high and steep</para>
			</text>
			<locn>
				<cond1>high</cond1>
				<cond2>steep</cond2>
			</locn>
			<level2>
				<text>
					<para>This level should be displayed only if the
conditions are high and steep</para>
				</text>
				<locn>
					<cond1>high</cond1>
					<cond2>steep</cond2>
				</locn>
			</level2>
		</level1>
	</test>
</root>

My sample XSLfo:

<?xml version="1.0" encoding="UTF-8"?>
<?altova_samplexml E:\User Profiles\n26353\My
Documents\DigitalData\AMDS-0.6.3\Issues\testdata.xml?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:variable name="val1">high</xsl:variable>
	<xsl:variable name="val2">deep</xsl:variable>
	<xsl:template match="root">
		<fo:root
xmlns:fo="http://www.w3.org/1999/XSL/Format">
			<fo:layout-master-set>
				<fo:simple-page-master master-name="coverPage"
page-height="11in" page-width="8.5in" margin-top="5mm"
margin-bottom="5mm" margin-left="5mm"
margin-right="5mm">
					<fo:region-body
region-name="coverPage-region-body" margin-left="8mm"
margin-right="8mm" margin-top="44mm"
margin-bottom="25mm">
					
					</fo:region-body>
					<fo:region-before
region-name="coverPage-region-before"
precedence="false" extent="44mm"/>
					<fo:region-after
region-name="coverPage-region-after"
precedence="false" extent="50mm"
display-align="after"/>
				</fo:simple-page-master>
				<fo:page-sequence-master master-name="cover">
					<fo:repeatable-page-master-reference
master-reference="coverPage"/>
				</fo:page-sequence-master>
			</fo:layout-master-set>
			<fo:page-sequence master-reference="cover"
font-family="Helvetica" font-size="10pt">
				<fo:static-content
flow-name="coverPage-region-before">
				
				
				</fo:static-content>
				<fo:static-content
flow-name="coverPage-region-after">
				
				</fo:static-content>
				<fo:flow flow-name="coverPage-region-body">
					<fo:block>
						<xsl:apply-templates select="test"/>
					</fo:block>
				</fo:flow>
			</fo:page-sequence>
		</fo:root>
	</xsl:template>
	<xsl:template match="test">
		<fo:block>
			<xsl:apply-templates/>
		</fo:block>
	</xsl:template>
	<xsl:template match="level1">
		<xsl:choose>
			<xsl:when test=".//locn">
				<xsl:if test=".//locn/cond1=$val1 and
.//locn/cond2=$val2">
					<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"/>
								</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:otherwise>
		<xsl:call-template name="level">
			<xsl:with-param name="format">1</xsl:with-param>
			</xsl:call-template>
</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="level2">
		<xsl:choose>
			<xsl:when test=".//locn">
				<xsl:if test=".//locn/cond1=$val1 and
.//locn/cond2=$val2">
					<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="A"/>
								</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:otherwise>		<xsl:call-template name="level">
			<xsl:with-param name="format">a</xsl:with-param>
			</xsl:call-template></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="level">
		<xsl:param name="format"/>
		<fo:list-block space-before="6pt"
space-before.conditionality="retain">
			<fo:list-item space-before="6pt">
				<fo:list-item-label end-indent="label-end()">
					<xsl:choose>
						<xsl:when test="$format = '1'">
							<fo:block>
								<fo:inline>
									<xsl:number format="1"/>.</fo:inline>
							</fo:block>
						</xsl:when>
						<xsl:when test="$format = 'A'">
							<fo:block>
								<fo:inline>
									<xsl:number format="A"/>.</fo:inline>
							</fo:block>
						</xsl:when>
						<xsl:when test="$format = '(1)'">
							<fo:block>
								<fo:inline>
									<xsl:number format="(1)"/>
								</fo:inline>
							</fo:block>
						</xsl:when>
						<xsl:when test="$format = '(1)'">
							<fo:block>
								<fo:inline>
									<xsl:number format="(1)"/>
								</fo:inline>
							</fo:block>
						</xsl:when>
						<xsl:when test="$format = '(a)'">
							<fo:block>
								<fo:inline>
									<xsl:number format="(a)"/>
								</fo:inline>
							</fo:block>
						</xsl:when>
						<xsl:when test="$format = '1)'">
							<fo:block>
								<fo:inline>
									<xsl:number format="1)"/>
								</fo:inline>
							</fo:block>
						</xsl:when>
						<xsl:when test="$format = 'a)'">
							<fo:block>
								<fo:inline>
									<xsl:number format="a)"/>
								</fo:inline>
							</fo:block>
						</xsl:when>
					</xsl:choose>
				</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:template>
</xsl:stylesheet>

The output PDF look has this:

1 This level should be displayed only if the
conditions are high and low.
A This level should be displayed only if the
conditions are high and deep.
2 This level should be displayed only if the
conditions are high and deep.

Now val1 and val 2 are high and deep. So the expected
output is: 

2 This level should be displayed only if the
conditions are high and deep.

However, instead of 2, it should be numbered 1 since
it is the first level.

Desired output on the PDF would be:

1. This level should be displayed only if the
conditions are high and deep.

Please let me know what my mistake is on this style
sheet. How can I filter the output as well as format
it correctly. 

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

> Well, no. I tried to ask you what the output really
> must look like. I 
> have several answers from you that give partial
> info. I can expect this:
> 
> 1 some text
> 1 some other text
> 1 yet other text
> 
> I can expect this:
> 1 some text
> 2 some other text
> 3 yet other text
> 
> I can expect this:
> 1 some text
>     a) some other text
>          ii) yet other text
> 
> I have no idea how to do this.You gave quite an
> extensive XML and it 
> gives all kinds of info, but it does not provide a
> clear clue of what 
> you want. Please:
> 1. diminish the XML by leaving out all non-important
> parts (but make 
> sure it is still valid XML)
> 2. Make a small XSLT that works on that partial XML
> (using your own, 
> partial working techniques)
> 3. run your small XSLT against the small XML and
> 4. show (1), (2) and (3) with explanations to us
> 
> That way, you can (almost) count on it to receive a
> quite quick and to 
> the point answer. It will save you and others a lot
> of time. 
> Furthermore, it will help yourself to understand the
> problem better. 
> Quite often, people find the solutions by narrowing
> the problem domain 
> or by writing down explanatory texts for others.
> 
> Cheers,
> -- Abel
>    http://www.nuntia.com
> 
> ms wrote:
> > Hi:
> >
> > Actually, the text "This has values high and
> steep"
> > was only to indicate that if the conditional
> values
> > were high and steep, then this text should be
> > displayed. The textual matter is not important.
> What
> > is important is the formatting for each level like
> 1,
> > 2, etc.
> >
> > Does that make sense? Please let me know if you
> need
> > more information. 
> >
> > Thanks a lot
> > MS
> > --- Abel Braaksma <abel.online@xxxxxxxxx> wrote:
> 
> 


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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent