output method = text or html

D

Derek Fountain

Just asked a question regarding this little bit of XSL:

---
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="html"/>

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

</xsl:stylesheet>
---

When run I get:
xsltproc test1.xsl test1.xml
' &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?
 
J

Johannes Koch

Derek said:
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.

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

Derek Fountain

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

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.
 
P

Patryk Dworznik

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

</xsl:stylesheet>
---

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top