Thomas J.S.: Problem mit Texten in Element bei Transformation

Beitrag lesen

Hallo,

Sorry, aber hä???
Die Doctype-Angabe brauchst du nicht. Du brauchst nur method="xml". Dem XSLT-Prozessor ist es ziemlich egal welche Doctype dein End-Dokument haben wird, er geht lediglich von der Angabe im method="" aus.

Ja das hätte ich auch gedacht, allerdings gibt es tatsächlich abhängig ob Doctype verwendet wird, eine andere Ausgabe:

<xsl:output method="html" indent="yes" omit-xml-declaration="yes" />


> liefert:  
> ~~~html
  

> <quiz>my name is <input type="text"> and i live in <input type="text">my pets name is <input type="text"> and his brothers name is <input type="text"></quiz>  
> 

Hier werden die input-tags nicht xhtml-konform geschlossen.

Ja, das ist normal.

<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />


> liefert:  
> ~~~html
  

> <quiz>my name is <input type="text"/> and i live in <input type="text"/>my pets name is <input type="text"/> and his brothers name is <input type="text"/></quiz>  
> 

Hier fehlt das Leerzeichen vor dem schließenden Slash.

Auch normal.
Aber das "weil ältere Browser" kann man mittlerweile vergessen.

<xsl:output method="xml" indent="yes"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" omit-xml-declaration="yes" />


> liefert:  
> ~~~html
  

> <!DOCTYPE quiz PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
> <quiz>my name is <input type="text" /> and i live in <input type="text" />my pets name is <input type="text" /> and his brothers name is <input type="text" /></quiz>  
> 

Hier ist alles perfekt, nur die Doctype-Erklärung steht halt im Ergebnis.

Interessant, welcher XSLT-Prozessor?

Grüße
Thomas