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
Alastair ScollaySubject: Using xsl to transfer XML data to a .pdf document
Author: Alastair Scollay
Date: 26 May 2006 01:37 AM
I am new to both XSL and to this forum, so apologies in advance if this has question already been asked.

I am trying to update an existing .xsl file to transfer XML data to a .pdf document.

(1) The section of XML data in question is in the following format:

<top-level-tag>
<second-level-tag>
<type-code>TOP</type-code>
<indent-level>0</indent-level>
<description>My first Description</description>
<total>0<total>
</second-level-tag>
<second-level-tag>
<type-code>SUB</type-code>
<indent-level>1</indent-level>
<description>My first sub description</description>
<total>15.0</capped-total>
</second-level-tag>
<second-level-tag>
<type-code>SUB</type-code>
<indent-level>1</indent-level>
<description>My second sub description</description>
<total>15.0</capped-total>
</second-level-tag>
<top-level-tag>
<second-level-tag>
<type-code>TOP</type-code>
<indent-level>0</indent-level>
<description>My Second Description</description>
<total>0<total>
</second-level-tag>
<second-level-tag>
<type-code>SUB</type-code>
<indent-level>1</indent-level>
<description>My third sub description</description>
<total>15.0</capped-total>
</second-level-tag>
<second-level-tag>
<type-code>SUB</type-code>
<indent-level>1</indent-level>
<description>My fourth sub description</description>
<total>15.0</capped-total>
</second-level-tag>
</top-level-tag>

(2) I want it to appear in the .pdf like this

My First Description
My first sub description
My second sub description
My Second Description
My third sub description
My fourth sub description

(3) Unfortunately, it's appearing as follows:

My First Description
My first sub description
My second sub description
My third sub description
My fourth sub description
My Second Description
My first sub description
My second sub description
My third sub description
My fourth sub description

(4) This is the code I currently have:

<xsl:for-each select="/filePath/moreFilePath/etc/second-level-tag[type-code='TOP']">
<fo:table-row>
<fo:table-cell>
<fo:block space-before="2mm"><xsl:value-of select="description"/></fo:block>
</fo:table-cell>
</fo:table-row>
<xsl:for-each select="/filePath/moreFilePath/etc/second-level-tag[type-code='SUB']">
<fo:table-row>
<fo:table-cell>
<fo:block space-before="2mm"><xsl:value-of select="description"/></fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block space-before="2mm" text-align="end" font-family="{$fixedfont}">
<!-- <xsl:if capped-total != '0'"> OLD CODE COMMENTED OUT-->
<xsl:value-of select="format-number(total,$currshort)"/>
<!-- </xsl:if> OLD CODE COMMENTED OUT -->
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>


I can understand the logic flaw in my code - it is grabbing EVERY sub description for EACH description but am not sure how to
amend this such that it only grabs the data I want for each section.

Any help is much appreciated!

Posttop
Ivan PedruzziSubject: Using xsl to transfer XML data to a .pdf document
Author: Ivan Pedruzzi
Date: 26 May 2006 01:59 AM

Hi Alastair,

I am sorry but we can't help you unless you provide a full working example that we can execute.

The XML posted is not well formed (see <total>15.0</capped-total>)
and the XSLT fragment is far too incomplete to understand why is not working.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

 
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.