AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein XML/XSL: Seite wird nicht korrekt angezeigt
Thema durchsuchen
Ansicht
Themen-Optionen

XML/XSL: Seite wird nicht korrekt angezeigt

Ein Thema von alcaeus · begonnen am 9. Sep 2008 · letzter Beitrag vom 9. Sep 2008
Antwort Antwort
Benutzerbild von alcaeus
alcaeus

Registriert seit: 11. Aug 2003
Ort: München
6.537 Beiträge
 
#1

XML/XSL: Seite wird nicht korrekt angezeigt

  Alt 9. Sep 2008, 21:07
Hallo allerseits,

um das Google-Chrome-Thema nicht unnoetig ins Off-Topic zu treiben stelle ich einfach mal hier die Frage. Ich hab aus Spass an der Freude mal damit rumexperimentiert, eine Website als XML auszuliefern und mit Hilfe von XSL-Stylesheets in vernuenftiges HTML umzuwandeln. Das Umwandeln klappt an sich ganz gut, aber bei der Anzeige hapert es. Der Code der Beispielseite ist simpel:
XML-Code:
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="forum.xsl" ?>
<forum id="1" name="Test-Forum">
   <header>
      <usernav>
         <item url="search.php">Suchen</item>
         <item url="login.php">Login</item>
      </usernav>
   </header>
   
   <topics>
      <topic id="1">
         <title>Test-Thema</title>
         <author id="1">
            <name>alcaeus</name>
         </author>
         <replies>14</replies>
      </topic>
      <topic id="2">
         <title>Foo</title>
         <author id="2">
            <name>hades</name>
         </author>
         <replies>0</replies>
      </topic>
   </topics>
</forum>
Den Code bzw. das Ergebnis koennt ihr hier einsehn. Das XSL-Stylesheet ist etwas laenger, aber immer noch simpel:
XML-Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" encoding="ISO-8859-1" omit-xml-declaration="no" doctype-public="" />

<xsl:template match="/forum">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" dir="ltr">
   <head>
      <title>Forum anzeigen: <xsl:value-of select="@name" /></title>
   </head>
   <body>
      <div id="header">
         [url="/"]<h1>Infler.de</h1>[/url]
         <xsl:apply-templates select="header" />
      </div>
      <a><xsl:attribute name="href">forum.xml?f=<xsl:value-of select="@id" /></xsl:attribute><h2><xsl:value-of select="@name" /></h2></a>
      <xsl:apply-templates select="topics" />
   </body>
</html>
</xsl:template>

<xsl:template name="topics" match="topics">
<ul>
   <xsl:for-each select="topic">
      [*]<xsl:value-of select="@id" />: <xsl:value-of select="title" /> von <xsl:value-of select="author/name" /> (<xsl:value-of select="replies" /> Antworten)
   </xsl:for-each>[/list]</xsl:template>

<xsl:template name="header" match="header">
   <xsl:for-each select="usernav">
      <ul>
         <xsl:for-each select="item">
            [*]<a><xsl:attribute name="href"><xsl:value-of select="@url" /></xsl:attribute><xsl:value-of select="." /></a>
         </xsl:for-each>
      [/list]   </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
(Online hier einsehbar)

Das Ergebnis sieht im IE6 wie erwartet kacke aus (ich hab hier keinen Screenshot, aber die Webdesigner wissen sicherlich was ich meine), was mich aber nicht weiter stoert. IE7 zeigt die Seite so an wie ich es erwarte. Firefox 2 und 3, Safari, Opera und auch Google Chrome zeigen aber alle dasselbe Bild. Einen Vergleich zwischen IE7 und Firefox 2 habe ich hier online gestellt. Alle Browser ausser dem IE7 zeigen die Seite so an, wie Firefox 2, die Liste wird nicht als Solche dargestellt, sondern die einzelnen Listenpunkte hintereinandergestellt.

Da ich es etwas eigenartig finde, dass im IE7 etwas korrekt angezeigt wird und in anderen Browsern nicht, obwohl ich mich meines Wissens nach an Standards gehalten hab, frage ich sicherheitshalber hier nach. Kann jemand im XML (glaube ich kaum) oder im XSL-Stylesheet (halte ich eher fuer wahrscheinlich) einen Fehler finden, der das Rendering in Firefox und Konsorten durcheinanderbringt? Kann es sein dass ich die Style-Informationen, die der Browser Standardmaessig laedt (also auch das Standard-Aussehen von Listen) alle explizit definieren muss?

Ich hoffe jemand kann mir weiterhelfen, kann ja nicht sein dass der IE7 als einziger Browser die Seite korrekt darstellt

Greetz
alcaeus
Andreas B.
Die Mutter der Dummen ist immer schwanger.
Ein Portal für Informatik-Studenten: www.infler.de
  Mit Zitat antworten Zitat
Benedikt
(Gast)

n/a Beiträge
 
#2

Re: XML/XSL: Seite wird nicht korrekt angezeigt

  Alt 9. Sep 2008, 21:42
Nabend,

hab grad mal ein wenig rumgespielt: Wenn du im xsl-output-Tag den optionalen Parameter method selbst setzt mit Wert "html", dann klappts

Also:

XML-Code:
...<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" encoding="ISO-8859-1" omit-xml-declaration="no" doctype-public="" />
<xsl:template match="/forum">...
MfG Benedikt
  Mit Zitat antworten Zitat
Benutzerbild von alcaeus
alcaeus

Registriert seit: 11. Aug 2003
Ort: München
6.537 Beiträge
 
#3

Re: XML/XSL: Seite wird nicht korrekt angezeigt

  Alt 9. Sep 2008, 21:45
Zitat von Benedikt:
hab grad mal ein wenig rumgespielt: Wenn du im xsl-output-Tag den optionalen Parameter method selbst setzt mit Wert "html", dann klappts
Ha, ich wusste dass es nicht sein kann, dass der IE das korrekt darstellt was andere nicht koennen. Dass die Loesung aber so banal ist, haette ich aber auch nicht gedacht

Danke vielmals

Greetz
alcaeus
Andreas B.
Die Mutter der Dummen ist immer schwanger.
Ein Portal für Informatik-Studenten: www.infler.de
  Mit Zitat antworten Zitat
Benutzerbild von jfheins
jfheins

Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
 
#4

Re: XML/XSL: Seite wird nicht korrekt angezeigt

  Alt 9. Sep 2008, 22:03
Vll. interessiert dich das hier noch:

Ich zitiere hier mal von dort: http://www.w3.org/TR/xslt#output

Zitat:
An XSLT processor may output the result tree as a sequence of bytes, although it is not required to be able to do so (see [17 Conformance]). The xslutput element allows stylesheet authors to specify how they wish the result tree to be output. If an XSLT processor outputs the result tree, it should do so as specified by the xslutput element; however, it is not required to do so.

The xslutput element is only allowed as a top-level element.

The method attribute on xslutput identifies the overall method that should be used for outputting the result tree. The value must be a QName. If the QName does not have a prefix, then it identifies a method specified in this document and must be one of xml, html or text. If the QName has a prefix, then the QName is expanded into an expanded-name as described in [2.4 Qualified Names]; the expanded-name identifies the output method; the behavior in this case is not specified by this document.

The default for the method attribute is chosen as follows. If

the root node of the result tree has an element child,

the expanded-name of the first element child of the root node (i.e. the document element) of the result tree has local part html (in any combination of upper and lower case) and a null namespace URI, and

any text nodes preceding the first element child of the root node of the result tree contain only whitespace characters,

then the default output method is html; otherwise, the default output method is xml. The default output method should be used if there are no xslutput elements or if none of the xslutput elements specifies a value for the method attribute.
Viel Spaß
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz