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

  • SEARCH
  • Home
  • 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 9064967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:23:15+00:00 2026-06-16T16:23:15+00:00

I am experiencing with xsl and pdf output. I have a xml file like

  • 0

I am experiencing with xsl and pdf output. I have a xml file like this:

<?xml version="1.0" encoding="utf-8" ?>
  <document>
    <header>
      <author>my name</author>
    </header>
    <body>
      <text>some text</text>
    </body>
  </document>

My xsl file looks like:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/">
  <fo:root>

    <fo:layout-master-set>
      <fo:simple-page-master
        master-name="_title"
        page-height="29.7cm"
        page-width="21cm"
        margin="3cm">
        <fo:region-body/>
      </fo:simple-page-master>

      <fo:simple-page-master
        master-name="_body"
        page-height="29.7cm"
        page-width="21cm"
        margin="3cm">
        <fo:region-body/>
      </fo:simple-page-master>

      <fo:page-sequence-master master-name="titlepage">
        <fo:single-page-master-reference master-reference="_title"/>
      </fo:page-sequence-master>

      <fo:page-sequence-master master-name="body">
        <fo:repeatable-page-master-reference master-reference="_body"/>
      </fo:page-sequence-master>

    </fo:layout-master-set>

    <fo:page-sequence master-reference="titlepage">
      <fo:flow flow-name="xsl-region-body" font-family="Courier" font-size="12pt">
        <fo:block>
          <xsl:apply-templates select="header"/>
        </fo:block>
      </fo:flow>
    </fo:page-sequence>

    <fo:page-sequence master-reference="body">
      <fo:flow flow-name="xsl-region-body" font-family="Courier" font-size="12pt">
        <fo:block>
          <xsl:apply-templates select="body"/>
        </fo:block>
      </fo:flow>
    </fo:page-sequence>
    </fo:root>
  </xsl:template>

  <xsl:template match="header">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="body">
    <xsl:apply-templates />
  </xsl:template>
</xsl:stylesheet>

I expect two pdf pages, first page with “my name” and a second one with “some text”. Instead I get two empty pages.

  • 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. Editorial Team
    Editorial Team
    2026-06-16T16:23:16+00:00Added an answer on June 16, 2026 at 4:23 pm

    Looking at your XSLT, you have the following template

    <xsl:template match="/">
    

    This matches the “document node” of the XML document. This is not the same as the top-level element of the XML document, which is document in your case. / is effectively the parent of the top-level element.

    What this means is that later on in your template, when you do the following apply-templates, like so

    <xsl:apply-templates select="header"/>
    <xsl:apply-templates select="body"/>
    

    These are effectively looking for top-level elements of header and body respectively. However, your header and body elements are child elements of your top-level document element.

    To solve this, you have a couple of choices. You could either replace your apply-templates with these:

    <xsl:apply-templates select="document/header"/>
    <xsl:apply-templates select="document/body"/>
    

    Alternatively, you can change your initial template to match the following (instead of just <xsl:template match="/">)

    <xsl:template match="/document">
    

    It is also worth noting, as Dimitre mentioned in his comment, in your templates for header and body, you are doing <xsl:apply-templates />. However, you have no templates matching any child elements of header or body. This means the default templates will kick-in, and just output the text of the elements instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experimenting with XSLT2, using a stylesheet based on this answer: <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform>
I experiencing a strange behavior of C#. Its some thing like this.. var date
When experiencing networking problems on client machines, I'd like to be able to run
Some reasons i am experiencing this issue on my website. When the website loads
I'm currently experiencing some problems with my server. I have a pool which is
I am experiencing a very weird problem: In WPF I have a tabControl which
I'm experiencing this on my code and I cannot figure out why. Basically I'm
I'm currently experiencing a problem with jQuery UI and many buttons. I have a
I have started experiencing errors in WCF deserialization today - in code which has
I am experiencing some strange behavior with SQL Server CE 3.5 SP2. I have

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.