XSL FO Formatierung (zum PDF)

Larsiki

Grünschnabel
Hallo!

Ich bin neu hier. Aber ich hoffe Ihr helft mir trotzdem bei meinen Problem.Ich muss aus XML Dateien eine FO-Datei generieren. Die XML Datei habe ich soweit fertig. Ich quäle mich seid Tagen mit der XSL-FO Datei. Den Apache habe ich zum laufen bekommen und getestet.
Wie binde ich meine xml in die XSL ein? Ich habe in der XSL schon die Seitenattribute definiert.
Habe beide Dateien in den Anhang gepack. Hoffe Ihr könnt mir schnell helfen. Die Zeit drängelt bei mir, aber mein wissen geht dem Ende nahe.

Vielen Dank!
 

Anhänge

  • xml.txt
    1,4 KB · Aufrufe: 89
  • xsl-fo.txt
    1,3 KB · Aufrufe: 104
Hilft mir leider kein Stück!

Aber Danke!

Hat jemand ne andere Idee oder kann mir sagen wie die XSL Datei aussehen muss?

Vielleicht auch kurz die Datei richtig erweitern!

Danke
 
hi larsiki,

die umwandlung von einem xml-dokument in ein pdf erfolgt in 2 schritten. du brsuchst zu deinem xml-dok ein stylesheet. diese beiden dateien kannst du dann mit hilfe eines xslt-prozessors in ein xsl-fo-dok umwandeln. dieses xsl-fo-dok. musst du dann mit einem fop in eine pdf umwandeln. alternativ kannst du natürlich auch dein xsl-fo-dokument von had schreiben :rolleyes: kann ich aber nicht empfehlen

gruß jens
 
naja und nachdem ich gerade mal ein blick in deine fo-datei geworfen habe ...
Code:
<fo:root xmlns:fo="http://www.w3c.org/1999/XSL/Format">
wäre das richtige wurzelelement

und dann überprüf mal die anderen tags, die stimmen nämlich auch nicht überein :suspekt:
 
Meine Datei sieht wie folgt aus inzwischen!

Richtig so?

Wie definiere ich jetzt einzelne Tags?

Danke

<?xml version="1.0" encoding="ISO-8859-1"?>

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

//root-Regel
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

//Umschließt die Definition für den Aufbau einzelner Seiten
<fo:layout-master-set>

//master-name definiert den Namen des Seitentyps
//page-height //Seitenhöhe
//page-width //Seitenbreite
//margin-top //Oberer Rand
//margin-button //Unterer Rand
//margin-left //Linker Rand
//margin-right //Rechter Rand
<fo:simple-page-master-name="Standard"
page-height="29.7cm"
page-width="21cm"
margin-top="2cm"
margin-button="2cm"
margin-left="2.5cm"
margin-right="2.5cm"
</fo:simple-page-master>
</fo:layout-master-set>
<xsl:apply-templates select="AbschreibungfuerAbnutzung"/>
</fo:root>
</xsl:template


<xsl:template match="AbschreibungfuerAbnutzung">

<fo:page-sequence master-name="Standard" >
<fo:flow flow-name="AbschreibungfuerAbnutzung">

// schriftgröße usw.

<xsl:apply-templates />
</fo:flow>

</fo:page-sequence>
</xsl:template>

<xsl:template match="Inhalt">
<fo:block font-size="20pt"
line-height="22pt"
color="#ff9900"
space-after.optimum="5pt"
space-before.optimum="5pt"
text-align="center">
<xsl:value-of select="."/>
</fo:block>
</xsl:template>

<xsl:template match="Ueberschrift1">
//schrift usw.
</xsl:template>
 
hi ...
soweit ich das jetzt beurteilen kann sieht das ganz gut aus (hab die syntax ja nicht mehr im kopf) - zumindest im groben sollte es richtig sein ... speicher die datei mal als test.fop ab und jag sie dann durch den fop des apache-xml-projektes mit
Code:
fop test.fop test.pdf
ich werd mal sehen ob ich noch irgendwo so ne fertige fop-datei hab

mal was ganz einfaches
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<fo:layout-master-set>
		<fo:simple-page-master margin-right="1cm"          margin-left="1cm"
                                   	                       margin-bottom="1.5cm"   margin-top="1cm"
                                               	           page-width="21cm"         page-height="29.6cm"
                                              		master-name="main">
				<fo:region-body/>
		</fo:simple-page-master>
	</fo:layout-master-set>

	<fo:page-sequence master-reference="main">
		<fo:flow flow-name="xsl-region-body">
			<fo:block font-size="20pt" font-weight="bold"
			  text-align="center">4. Semester</fo:block>
			<fo:block font-size="15pt" text-align="left" font-weight="bold">Pflichtfächer</fo:block>
			<fo:list-block>
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Datenbanken 1
				</fo:block></fo:list-item-body></fo:list-item>
				
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Nachrichtentechnik
				</fo:block></fo:list-item-body></fo:list-item>
				
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Rechnerarchitektur
				</fo:block></fo:list-item-body></fo:list-item>
				
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Softwareengineering
				</fo:block></fo:list-item-body></fo:list-item>
				
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Multimediaprogrammierung
				</fo:block></fo:list-item-body></fo:list-item>
			</fo:list-block>

			<fo:block font-size="15pt" text-align="left" font-weight="bold" >Wahlpflichtfächer</fo:block>
			<fo:list-block>
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Operations Research
				</fo:block></fo:list-item-body></fo:list-item>
				
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Spezielle Kapitel der praktischen Informatik
				</fo:block></fo:list-item-body></fo:list-item>
				
				<fo:list-item><fo:list-item-label><fo:block>•</fo:block>
				</fo:list-item-label><fo:list-item-body><fo:block start-indent="16pt">
				   Projektmangement
				</fo:block></fo:list-item-body></fo:list-item>
			</fo:list-block>
			
</fo:flow></fo:page-sequence></fo:root>
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück