output method = text or html

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Derek Fountain

    output method = text or html

    Just asked a question regarding this little bit of XSL:

    ---
    <?xml version="1.0"?>
    <xsl:styleshe et version="1.0"
    xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>

    <xsl:template match="/">
    <xsl:text>&apos ; &lt; &gt; &quot; &amp;</xsl:text>
    </xsl:template>

    </xsl:stylesheet>
    ---

    When run I get:
    [color=blue]
    >xsltproc test1.xsl test1.xml[/color]
    ' &lt; &gt; &quot; &amp;

    i.e. the &lt; etc. aren't being converted to <, etc., (although the &apos;
    does).

    Someone told me to change the method="html" to method="text" and that indeed
    fixed the problem. My question now, is, why?

    My required final output is actually HTML (not XHTML, it's going into a
    legacy application which I can't re-engineer) so I need to be able to put
    out things like unclosed <p>'s and the like. If I put them directly in my
    XSL I get errors saying it's not a well formed document - which of course
    it isn't. If I use &lt;p&gt; then they don't get converted unless I use an
    output method of "text".

    Can someone help me understand what's happening here - either with an
    explanation or a URL I can read?
  • Johannes Koch

    #2
    Re: output method = text or html

    Derek Fountain wrote:[color=blue]
    > My required final output is actually HTML (not XHTML, it's going into a
    > legacy application which I can't re-engineer) so I need to be able to put
    > out things like unclosed <p>'s and the like.[/color]

    Why do you think you _need_ this? In HTML, the end tag of the p element
    is _optional_ but _not forbidden_.

    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)

    Comment

    • Derek Fountain

      #3
      Re: output method = text or html

      Johannes Koch wrote:
      [color=blue]
      > Derek Fountain wrote:[color=green]
      >> My required final output is actually HTML (not XHTML, it's going into a
      >> legacy application which I can't re-engineer) so I need to be able to put
      >> out things like unclosed <p>'s and the like.[/color]
      >
      > Why do you think you _need_ this? In HTML, the end tag of the p element
      > is _optional_ but _not forbidden_.[/color]

      The output of my XSL isn't going into an HTML renderer. Someone before my
      time had the bright idea to use HTML is a config file format, but only
      implemented enough of a parser to do the job required. This parser has its
      own ideas about what's optional and forbidden. In this case putting a
      closing </p> tag in confuses it.

      Comment

      • Patryk Dworznik

        #4
        Re: output method = text or html

        On Wed, 13 Aug 2003 18:43:26 +0800, Derek Fountain wrote:

        [color=blue]
        >
        > <xsl:template match="/">
        > <xsl:text>&apos ; &lt; &gt; &quot; &amp;</xsl:text>
        > </xsl:template>
        >
        > </xsl:stylesheet>
        > ---[/color]

        Try <xsl:text disable-output-escaping="yes"> </xsl:text>
        to prevent characters from being escaped.

        --
        Patryk Dworznik

        Comment

        Working...