Quoting confusion

D

Derek Fountain

How do I get a three character string like

<p>

in my output? It thought using &lt;p&gt; should do it, but no. I get the
literal characters.

As a test I wrote this little bit of XSLT:

---
<?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;

The &apos; seems to convert to a ' correctly, but the others come out
literally. That's under Linux with libxml2, but I'm seeing the same issues
on Windows.

What have I done wrong?
 
N

Nicolas Stern

Hi Derek

I solved the problem this way:

- use output method="text"
- put your text in a cdata segment

Hope this helps - regards - Nicolas Stern

sample code for the xsl stylesheet:
------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="text" />

<xsl:template match="/">
<![CDATA[
<html>
<body>
<h1>Test</h1>
<h2> 1 < 2 </h2>
</body>
</html>
]]>

</xsl:template>
 
D

Derek Fountain

I solved the problem this way:
- use output method="text"

That appears to be the key. The CDATA stuff you also implemented wasn't
necessary, either for my project, or my little test script.

Now I need to understand why the output method changes the way these things
behave. I'll start a new thread for that.

Thanks for your help!
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top