Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 144949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:20:12+00:00 2026-05-11T08:20:12+00:00

At work I’ve been given the fun task of generating PDFs with XSL. The

  • 0

At work I’ve been given the fun task of generating PDFs with XSL. The XML structure I’m working with is similar to

<records>     <topLevel>         <topLevelID></topLevelID>         <secondLevel>             <secondLevelID></secondLevelID>             <thirdLevel>             </thirdLevel>             <thirdLevel>             </thirdLevel>         </secondLevel>     </topLevel>     <topLevel>         <topLevelID></topLevelID>         <secondLevel>             <secondLevelID></secondLevelID>             <thirdLevel>             </thirdLevel>             <thirdLevel>             </thirdLevel>         </secondLevel>     </topLevel> </records> 

I would try to give a more meaningful example of the XML, but I don’t feel like approaching any legal boundaries that may exist. With that XML structure, I have to output a block of text in the PDF for every thirdLevel node. The XSL I have so far is like

<xsl:for-each select ='topLevel'>               <xsl:variable name='topID' select='topLevelID'/>     <xsl:for-each select ='secondLevel'>         <xsl:variable name='secondID' select='secondLevelID'/>         <xsl:for-each select='thirdLevel'>                         <fo:block-container position='absolute' height='12.8pt' width='220.8pt' left='160pt' display-align='auto'>                 <xsl:attribute name='top'>                     <xsl:value-of select='concat(193 + [whatshouldgohere]), 'pt')'/>                 </xsl:attribute>                 <fo:block font-size='7pt'>                                               <xsl:call-template name='insertThirdLevel'/>                 </fo:block>             </fo:block-container>         </xsl:for-each>     </xsl:for-each> </xsl:for-each> 

Basically, I need to add some value to the top attribute to make the text for each thirdLevel node appear on its own line. I’ve tried using combinations of adding/multiplying by the ID (starts at 1 and increases by 1 for each set) and position(), but I can’t seem to get it right.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:20:13+00:00Added an answer on May 11, 2026 at 8:20 am

    I think you should really look into <xsl:apply-templates>, it can save you a lot of typing.

    Simplified version:

    <xsl:variable name='line-height' select='10' />  <xsl:template match='/records'>   <xsl:apply-templates select='//thirdLevel' /> </xsl:template>  <xsl:template match='thirdLevel'>   <xsl:variable name='top' select='193 + position() * $line-height' />   <fo:block-container top='{concat($top , 'pt')}'>     <fo:block font-size='7pt'>                                 <xsl:call-template name='insertThirdLevel'/>     </fo:block>   </fo:block-container> </xsl:template>  <xsl:template name='insertThirdLevel'>   Third Level! </xsl:template> 

    Simplified output (‘fo’ namespace excluded):

    <fo:block-container top='203pt'>   <fo:block font-size='7pt'>     Third Level!   </fo:block> </fo:block-container> <fo:block-container top='213pt'>   <fo:block font-size='7pt'>     Third Level!   </fo:block> </fo:block-container> <fo:block-container top='223pt'>   <fo:block font-size='7pt'>     Third Level!   </fo:block> </fo:block-container> <fo:block-container top='233pt'>   <fo:block font-size='7pt'>     Third Level!   </fo:block> </fo:block-container> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The effectiveness of this approach depends on, amongst other things,… May 11, 2026 at 12:17 pm
  • added an answer As you probably know, the standard Rails way of running… May 11, 2026 at 12:17 pm
  • added an answer it sounds like this attribute isn't marked as safe for… May 11, 2026 at 12:17 pm

Related Questions

At work I am responsible for writing specifications quite often and I am also
At work I'm using Perl 5.8.0 on Windows. When I first put Perl on,
At work I have a standard desk (4 legs, flat surface, you get the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.