Quoting confusion

Discussion in 'XML' started by Derek Fountain, Aug 13, 2003.

  1. 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?
     
    Derek Fountain, Aug 13, 2003
    #1
    1. Advertisements

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

    </xsl:stylesheet>
     
    Nicolas Stern, Aug 13, 2003
    #2
    1. Advertisements

  3. > 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!
     
    Derek Fountain, Aug 13, 2003
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. xyZed
    Replies:
    8
    Views:
    536
    xyZed
    Apr 5, 2006
  2. yoni
    Replies:
    12
    Views:
    934
  3. jsnX

    quoting quotes, &c.

    jsnX, Apr 5, 2005, in forum: C++
    Replies:
    1
    Views:
    421
    Victor Bazarov
    Apr 5, 2005
  4. David M. Wilson
    Replies:
    6
    Views:
    485
    David M. Wilson
    Dec 14, 2003
  5. Matthias Teege

    quoting %

    Matthias Teege, Oct 13, 2004, in forum: Python
    Replies:
    8
    Views:
    616
    Dan Sommers
    Oct 16, 2004
  6. Xah Lee

    20050119: quoting strings

    Xah Lee, Jan 10, 2005, in forum: Python
    Replies:
    1
    Views:
    340
    Steve Holden
    Jan 10, 2005
  7. snacktime

    Quoting sql queries with the DB-API

    snacktime, Jan 24, 2005, in forum: Python
    Replies:
    2
    Views:
    356
    snacktime
    Jan 24, 2005
  8. seven.reeds
    Replies:
    2
    Views:
    189
    seven.reeds
    Jun 21, 2006
Loading...