Why do I get the output twice in my pdf from my xml, xslt?

I get my output twice in my pdf file. Look at my pdf.....and my xml code
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
 <xsl:template match="/">
 

 <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
   <fo:layout-master-set>
     <fo:simple-page-master master-name="simple"
                   page-height="29.7cm" 
                   page-width="21cm"
                   margin-top="1cm" 
                   margin-bottom="2cm" 
                   margin-left="2.5cm" 
                   margin-right="2.5cm">
       <fo:region-body margin-top="3cm"/>
       <fo:region-before extent="3cm"/>
       <fo:region-after extent="1.5cm"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
 
 
   <fo:page-sequence master-reference="simple">
   	<fo:flow flow-name="xsl-region-body">
   	       <xsl:apply-templates select="data"/>
   	</fo:flow>
   </fo:page-sequence>

  </fo:root> 
 </xsl:template>
 
 <xsl:template match="data">
       <fo:block>
       	<xsl:apply-templates select="name"/>
        <xsl:apply-templates select="header1"/>
       	<xsl:apply-templates select="section1"/>
        <xsl:apply-templates select="header2"/>
        <xsl:apply-templates select="section2"/>
        
       </fo:block>
 </xsl:template>
 
 <xsl:template match="name">       
       <fo:block font-size="18pt" 
             font-family="sans-serif" 
             line-height="24pt"
             space-after.optimum="15pt"
             background-color="gray"
             color="white"
             text-align="center"
             padding-top="3pt">
         <xsl:value-of select="."/>
       </fo:block> 
 </xsl:template>
 
 <xsl:template match="header1 | header2">
       <fo:block font-size="12pt" 
                 font-family="sans-serif" 
                 line-height="15pt"
                 space-after.optimum="3pt"
                 text-align="justify">
		<xsl:value-of select="."/>
	</fo:block>
</xsl:template>


 <xsl:template match="section1">
       <fo:block font-size="10pt"
                 font-family="sans-serif"
                 line-height="10pt"
                 space-after.optimum="3pt"
                 text-align="justify">
                  <xsl:apply-templates select="para1"/>
                 <xsl:apply-templates select="paraspecial"/>
                 <xsl:apply-templates select="para3"/>
                 <xsl:apply-templates select="para4"/>
                 <xsl:apply-templates select="para5"/>
                 <xsl:apply-templates select="para6"/>
                 <xsl:apply-templates select="para7"/>
                 <xsl:apply-templates select="para8"/>
                 <xsl:apply-templates select="para9"/>
                 <xsl:apply-templates select="para10"/>
                 <xsl:value-of select="."/>
	</fo:block>

</xsl:template>



 <xsl:template match="para1 | para2 | para3 | para4 | para5| para6 | para7 | para8 | para9 | para10">
                    <fo:block font-size="10pt"
                 font-family="sans-serif"
                 line-height="10pt"
                 space-after.optimum="3pt"
                 text-align="justify">
		<xsl:value-of select="."/>
	</fo:block>
</xsl:template>

  <xsl:template match="paraspecial">
       <fo:block font-size="10pt"
             font-family="sans-serif"
             line-height="10pt"
             space-after.optimum="3pt"
             background-color="gray"
             color="white"
             text-align="justify">
         <xsl:value-of select="."/>
       </fo:block>
 </xsl:template>




 <xsl:template match="section2">
       <fo:block font-size="10pt"
                 font-family="sans-serif"
                 line-height="10pt"
                 space-after.optimum="3pt"
                 text-align="justify">
                  <xsl:apply-templates select="para1"/>
                 <xsl:apply-templates select="para2"/>
                 <xsl:apply-templates select="para3"/>
                 <xsl:apply-templates select="para4"/>
                 <xsl:apply-templates select="para5"/>
                 <xsl:apply-templates select="para6"/>
                 <xsl:apply-templates select="para7"/>
                 <xsl:apply-templates select="para8"/>
                 <xsl:apply-templates select="para9"/>
                 <xsl:apply-templates select="para10"/>
                 <xsl:value-of select="."/>
	</fo:block>

</xsl:template>
 
 </xsl:stylesheet>
 

---------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<data>
	<name>
		Inlämning 1
	</name>
        <header1>1.	Inledning</header1>
	<section1>
            <para1>Den första uppgiften i ), XML-teknik, som skall lösas är denna uppgift. Följande var givet för uppgiften:</para1>
            <paraspecial>Instruktioner:</paraspecial>
            <para3>Uppgift 1  Vad är XML?</para3>
            <para4>XML, stylesheet, DocBook, schema, SVG, SGML, HTML, S1000D, editor, verifiering, W3C, DTD, CSS, XSL, XSLT, Arbortext.
                Listan på XML-relaterade begrepp verkar i det närmaste oändlig. Vad betyder de olika begreppen, hur hänger de här begreppen
                ihop, finns det fler intressanta och viktiga begrepp? Vem styr XML och dess utveckling? Vilka aktörer finns är det oberoende
                standardiseringsorgan eller stora programvarutillverkare?</para4>
            <para5>VAD</para5>
            <para6>Din uppgift består av följande delar:</para6>
            <para7>1. Definiera huvudbegrepp inom XML-sfären såsom till exempel stylesheet, DocBook, CSS och W3C. För att få ett grepp om vilka som är viktiga att förstå kan kurslitteraturen samt länkarna i kursmiljön vara till god hjälp.</para7>
            <para8>2. Relatera de olika begreppen till varandra. Finns det begrepp som på något sätt kan sägas vara varianter av något med samma funktion?</para8>
            <para9>3. Vem styr XML och dess utveckling. Beskriv vilka aktörer som finns inom XML-sfären, vilka är det som styr utvecklingen? Vilka effekter kan den här typen av styrning ha?</para9>
            <para10>Syftet med denna övning var att lära sig Vad XML är och alla dess begrepp.</para10>

        </section1>

        <header2>2.	Lösning</header2>
        <section2>
            <para1>1111111111</para1>
            <para2>22222222222</para2>
            <para3>33333333333333333</para3>
            <para4>4444444444444</para4>
            <para5>555555555555</para5>
            <para6>666666666666</para6>
            <para7>66666666666</para7>
            <para8>7777777777777</para8>
            <para9>888888888</para9>
            <para10>9999999999</para10>


        </section2>
</data>

Open in new window

ResultXML2PDF.pdf
MickeysAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
simply because you output the data twice

In the templates for section1 and section2 you have a value-of after all the apply-templates
you should remove that line
as an exampe I did it for section1
    <xsl:template match="section1"> 
        <fo:block font-size="10pt" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:apply-templates select="para1"/> 
            <xsl:apply-templates select="paraspecial"/> 
            <xsl:apply-templates select="para3"/> 
            <xsl:apply-templates select="para4"/> 
            <xsl:apply-templates select="para5"/> 
            <xsl:apply-templates select="para6"/> 
            <xsl:apply-templates select="para7"/> 
            <xsl:apply-templates select="para8"/> 
            <xsl:apply-templates select="para9"/> 
            <xsl:apply-templates select="para10"/> 
            <!--<xsl:value-of select="."/> -->
        </fo:block> 

Open in new window

0
Geert BormansInformation ArchitectCommented:
I rewrote your stylesheet so it is a bit more readable,
it would be easier to spot errors like this
<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
    <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/> 
    <xsl:template match="/"> 
        
        
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
            
            <fo:layout-master-set> 
                <fo:simple-page-master master-name="simple" 
                    page-height="29.7cm"  
                    page-width="21cm" 
                    margin-top="1cm"  
                    margin-bottom="2cm"  
                    margin-left="2.5cm"  
                    margin-right="2.5cm"> 
                    <fo:region-body margin-top="3cm"/> 
                    <fo:region-before extent="3cm"/> 
                    <fo:region-after extent="1.5cm"/> 
                </fo:simple-page-master> 
            </fo:layout-master-set> 
            
            
            <fo:page-sequence master-reference="simple"> 
                <fo:flow flow-name="xsl-region-body"> 
                    <xsl:apply-templates select="data"/> 
                </fo:flow> 
            </fo:page-sequence> 
            
        </fo:root>  
    </xsl:template> 
    
    <xsl:template match="data"> 
        <fo:block> 
            <xsl:apply-templates select="*"/> 
        </fo:block> 
    </xsl:template> 
    
    <xsl:template match="name">        
        <fo:block font-size="18pt"  
            font-family="sans-serif"  
            line-height="24pt" 
            space-after.optimum="15pt" 
            background-color="gray" 
            color="white" 
            text-align="center" 
            padding-top="3pt"> 
            <xsl:value-of select="."/> 
        </fo:block>  
    </xsl:template> 
    
    <xsl:template match="header1 | header2"> 
        <fo:block font-size="12pt"  
            font-family="sans-serif"  
            line-height="15pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:value-of select="."/> 
        </fo:block> 
    </xsl:template> 
    
    
    <xsl:template match="section1"> 
        <fo:block font-size="10pt" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:apply-templates select="*"/> 
        </fo:block> 
        
    </xsl:template> 
    
    <xsl:template match="*[translate(name(), '0123456789', '') = 'para']"> 
        <fo:block font-size="10pt" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:value-of select="."/> 
        </fo:block> 
    </xsl:template> 
    
    <xsl:template match="paraspecial"> 
        <fo:block font-size="10pt" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            background-color="gray" 
            color="white" 
            text-align="justify"> 
            <xsl:value-of select="."/> 
        </fo:block> 
    </xsl:template> 
    
    <xsl:template match="section2"> 
        <fo:block font-size="10pt" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:apply-templates select="*"/> 
        </fo:block> 
        
    </xsl:template> 
    
</xsl:stylesheet> 

Open in new window

0
MickeysAuthor Commented:
I think your template looks just fine. I just have one question. If I use that how the heck do I get newline (enter) into my pdf?

I have tried and tried but I wont get it to work. I want it to be output just like I write a word document

Header

Underheader
text text text text text text text text text text text text text text text text text text .text text text text text text text text text .text text text text text text text text text .text text text text text text text text text

text text text text text text text text text text text text text text text .text text text text text text text text text text text text text text text text text text text text text .

text text text text text text text text text text text text . text text text text text text text text text

Under header

text text text text text text text text text text text text text text text . text text text text text text text text text .text text text text text text text text text text text text

text text text text text text text text text text text text ..text text text text text text text text text text text text .text text text text text text .
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Geert BormansInformation ArchitectCommented:
well, my new stylesheet did not change anything but less complex syntax.
The newlines are in the fo:block, and those are still there
I am off to bed now, I will check what goes wrong tomorrow morning
0
MickeysAuthor Commented:
Well I tried your xsl and it looks much easier to read and seems to be alot better. :-)

But look at my pdf. I would like to have newlines. How do I managed that? Right now the text just comes after each other.

I cant fiugre it out
ResultXML2PDF.pdf
0
Geert BormansInformation ArchitectCommented:
Let me guess by the way. Swedisch?
God morgon!

I must say that I don't understand the problem. The fo:block introduces a new blockelement in your output,
forcing it to start on a new line. You do that for each construct. So I am not sure what you want. I see "hard returns" in teh PDF you send.
Do you want more spacing?
Or do you want to reproduce the newlines, as they are in para4? That will be a bit tricky, cause you also have too much spaces there.
Can you be a bit more specific of what exactly you need?
0
MickeysAuthor Commented:
hehe Ja svensk. :-)

Yes the problem is that between the sections I would like to have a new line. So if it looks like this now


1. Inledning
Den första uppgiften i ), XML-teknik, som skall lösas är denna uppgift. Följande var givet för uppgiften:
Instruktioner:
Uppgift 1  Vad är XML?
XML, stylesheet, DocBook, schema, SVG, SGML, HTML, S1000D, editor, verifiering, W3C, DTD, CSS,
XSL, XSLT, Arbortext. Listan på XML-relaterade begrepp verkar i det närmaste oändlig. Vad betyder
de olika begreppen, hur hänger de här begreppen ihop, finns det fler intressanta och viktiga begrepp?
Vem styr XML och dess utveckling? Vilka aktörer finns är det oberoende standardiseringsorgan eller
stora programvarutillverkare?
VAD
Din uppgift består av följande delar:


I would like it to look like this

1. Inledning

Den första uppgiften i ), XML-teknik, som skall lösas är denna uppgift. Följande var givet för uppgiften:

Instruktioner:

Uppgift 1  Vad är XML?
XML, stylesheet, DocBook, schema, SVG, SGML, HTML, S1000D, editor, verifiering, W3C, DTD, CSS,
XSL, XSLT, Arbortext. Listan på XML-relaterade begrepp verkar i det närmaste oändlig. Vad betyder
de olika begreppen, hur hänger de här begreppen ihop, finns det fler intressanta och viktiga begrepp?
Vem styr XML och dess utveckling? Vilka aktörer finns är det oberoende standardiseringsorgan eller
stora programvarutillverkare?

VAD
Din uppgift består av följande delar:
.......
0
MickeysAuthor Commented:
asch......copy paste error.

Here you go again



Instruktioner:

Uppgift 1

Vad är XML?
XML, stylesheet, DocBook, schema, SVG, SGML, HTML, S1000D, editor, verifiering, W3C, DTD, CSS,
XSL, XSLT, Arbortext. Listan på XML-relaterade begrepp verkar i det närmaste oändlig. Vad betyder
de olika begreppen, hur hänger de här begreppen ihop, finns det fler intressanta och viktiga begrepp?
Vem styr XML och dess utveckling? Vilka aktörer finns är det oberoende standardiseringsorgan eller
stora programvarutillverkare?

VAD
Din uppgift består av följande delar:


I would like it to look like this

1. Inledning

Den första uppgiften i ), XML-teknik, som skall lösas är denna uppgift. Följande var givet för uppgiften:

Instruktioner:

Uppgift 1

Vad är XML?

XML, stylesheet, DocBook, schema, SVG, SGML, HTML, S1000D, editor, verifiering, W3C, DTD, CSS,
XSL, XSLT, Arbortext. Listan på XML-relaterade begrepp verkar i det närmaste oändlig. Vad betyder
de olika begreppen, hur hänger de här begreppen ihop, finns det fler intressanta och viktiga begrepp?
Vem styr XML och dess utveckling? Vilka aktörer finns är det oberoende standardiseringsorgan eller
stora programvarutillverkare?

VAD
Din uppgift består av följande delar:
.......
0
MickeysAuthor Commented:
by the way. I do have one question but I think it is better if you e-mail me.
nero2000 at hotmai dot com
0
Geert BormansInformation ArchitectCommented:
Oh, what you need is space-before attribute in each block
eg. <fo:block space-before="5mm"

Here is the XSLT, changed for that, you might want to play with the size a bit
0
Geert BormansInformation ArchitectCommented:
and now with XSLT
<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
    <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/> 
    <xsl:template match="/"> 
        
        
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> 
            
            <fo:layout-master-set> 
                <fo:simple-page-master master-name="simple" 
                    page-height="29.7cm"  
                    page-width="21cm" 
                    margin-top="1cm"  
                    margin-bottom="2cm"  
                    margin-left="2.5cm"  
                    margin-right="2.5cm"> 
                    <fo:region-body margin-top="3cm"/> 
                    <fo:region-before extent="3cm"/> 
                    <fo:region-after extent="1.5cm"/> 
                </fo:simple-page-master> 
            </fo:layout-master-set> 
            
            
            <fo:page-sequence master-reference="simple"> 
                <fo:flow flow-name="xsl-region-body"> 
                    <xsl:apply-templates select="data"/> 
                </fo:flow> 
            </fo:page-sequence> 
            
        </fo:root>  
    </xsl:template> 
    
    <xsl:template match="data"> 
        <fo:block> 
            <xsl:apply-templates select="*"/> 
        </fo:block> 
    </xsl:template> 
    
    <xsl:template match="name">        
        <fo:block font-size="18pt"  
            space-before="5mm" 
            font-family="sans-serif"  
            line-height="24pt" 
            space-after.optimum="15pt" 
            background-color="gray" 
            color="white" 
            text-align="center" 
            padding-top="3pt"> 
            <xsl:value-of select="."/> 
        </fo:block>  
    </xsl:template> 
    
    <xsl:template match="header1 | header2"> 
        <fo:block font-size="12pt"  
            space-before="5mm" 
            font-family="sans-serif"  
            line-height="15pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:value-of select="."/> 
        </fo:block> 
    </xsl:template> 
    
    
    <xsl:template match="section1"> 
        <fo:block font-size="10pt" 
            space-before="5mm" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:apply-templates select="*"/> 
        </fo:block> 
        
    </xsl:template> 
    
    <xsl:template match="*[translate(name(), '0123456789', '') = 'para']"> 
        <fo:block font-size="10pt" 
            space-before="5mm" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:value-of select="."/> 
        </fo:block> 
    </xsl:template> 
    
    <xsl:template match="paraspecial"> 
        <fo:block font-size="10pt" 
            space-before="5mm" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            background-color="gray" 
            color="white" 
            text-align="justify"> 
            <xsl:value-of select="."/> 
        </fo:block> 
    </xsl:template> 
    
    <xsl:template match="section2"> 
        <fo:block font-size="10pt" 
            space-before="5mm" 
            font-family="sans-serif" 
            line-height="10pt" 
            space-after.optimum="3pt" 
            text-align="justify"> 
            <xsl:apply-templates select="*"/> 
        </fo:block> 
        
    </xsl:template> 
    
</xsl:stylesheet> 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MickeysAuthor Commented:
This was exactlly what I was after. Are gonna open a new thread with other questions on this. Hope to see you there!!
0
Geert BormansInformation ArchitectCommented:
welcome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.