Thomas J.S.: XSLT 2.0 <xsl:result-document>

Beitrag lesen

Hallo,

Zu CSS: dein Ergebnisdokument beginnt mit <p>, d.h. alles was vorher in der HTML-Datei stehen sollte fehlt.

Das steht im Stylesheet weiter oben. Siehe Quelltext unten.

So funktioniert aber das nicht, result-document funktioniert nicht so.

Und außerdem, sind die Infos (der Code) leider zu wenig um alles nachvollziehen zu können.

Hier mein Quelltext:

OK, (ist nicht böse gemeint, sondern nur eine Feststellung) dein Stylesheet kann so überhaupt nicht funktioneren.

Willst du HTML erzegen gehört "xmlns:fo="http://www.w3.org/1999/XSL/Format" weg.

xsl:result-document darf nicht als Kind vom xsl:stylesheet auftreten.
xsl:result-document darf nicht xsl:template als Kind enthalten.

Du möchtest zwar mehrere Dokumente erzeugen, aber jedoch willst du nur ein Dokument haben, so kann das natürlich nicht funktioneren.

Ich habe mit einer dummy-xml:
------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<Konstruktionsprozeß>
   <Dokumentation>
      <Kapitel id="1">
         <KapitelUeberschrift>Kapitel 1</KapitelUeberschrift>
         <KapitelText></KapitelText>
         <KapitelBild nr="1" src="kap11.gif" width="100" height="75">Kap 1 Bild 1</KapitelBild>
      </Kapitel>
      <Kapitel id="2">
         <KapitelUeberschrift>Kapitel 2</KapitelUeberschrift>
         <KapitelText></KapitelText>
         <KapitelBild nr="1" src="kap21.gif" width="100" height="75">Kap 2 Bild 1</KapitelBild>
         <KapitelBild nr="1" src="kap22.gif" width="100" height="75">Kap 2 Bild 2</KapitelBild>
      </Kapitel>
      <FormaleErschließung>
            FormaleErschließung
      </FormaleErschließung>
   </Dokumentation>
</Konstruktionsprozeß>
---------------------------------------

und mit dem folgenden Stylesheet:
---------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output encoding="ISO-8859-1" indent="yes" method="html"/>
   <!-- Startvorlage-->
   <xsl:template match="/Konstruktionsprozeß/Dokumentation/Kapitel">
      <xsl:result-document href="Kapitel{@id}.html">
         <html>
            <head>
               <title>Dokumentation zum Konstruktionsprozeß Vobes-Plus</title>
               <!-- interne CSS -->
               <style type="text/css"> h1 { font-size: large; /* 30pt */ font-family: Arial; } h3 { color: blue; /* Warning: To help avoid conflicts with user style sheets, background and color properties should be specified together. */ font-size: large; /* 25pt */ font-family:Arial; } hr { width:100%; color: red; } p { font-size: xx-large; /* 30pt */ font-family:Arial; white-space:normal;
                  /*white-space erzeugt einen Textumbruch normal wie in HTML*/ margin-left:30px; margin-right:55px; } body{ margin-left: 100px; margin-right: 100px; } </style>
            </head>
            <body>
               <h1>Dokumentation</h1>
               <h3>
                  <xsl:value-of select="KapitelUeberschrift"/>
               </h3>
               <xsl:apply-templates select="KapitelText"/>
               <br/>
               <xsl:apply-templates select="KapitelBild"/>
               <br/>
            </body>
         </html>
      </xsl:result-document>
   </xsl:template>
   <xsl:template match="KapitelBild">
      <img alt="{@src}" heigth="{@height}" src="Bilder/{@src}" width="{@width}"/>
   </xsl:template>
   <xsl:template match="KapitelText">
      <p>
         <xsl:value-of select="."/>
      </p>
   </xsl:template>
</xsl:stylesheet>
-------------------------------------------

Die Dokumente erzuegen können:
-------------------------------------------
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>Dokumentation zum Konstruktionsprozeß Vobes-Plus</title><style type="text/css"> h1 { font-size: large; /* 30pt */ font-family: Arial; } h3 { color: blue; /* Warning: To help avoid conflicts with user style sheets, background and color properties should be specified together. */ font-size: large; /* 25pt */ font-family:Arial; } hr { width:100%; color: red; } p { font-size: xx-large; /* 30pt */ font-family:Arial; white-space:normal;
                  /*white-space erzeugt einen Textumbruch normal wie in HTML*/ margin-left:30px; margin-right:55px; } body{ margin-left: 100px; margin-right: 100px; } </style></head>
   <body>
      <h1>Dokumentation</h1>
      <h3>Kapitel 1</h3>
      <p></p><br><img alt="kap11.gif" heigth="75" src="Bilder/kap11.gif" width="100"><br></body>
</html>
----------------------------------------------

Prozessor ist Saxon 8.6  bzw. der XSLT2-Prozessor in XML-Spy.

Was ist dein Ziel was du erreichen möchtest?

Grüße
Thomas