SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Diving into XML - Errors

    Ok, so I thought I'd dabble my feet in XML with PHP tonight. Very simple thing I'm trying to do. Get the latest version of some software.

    I wrote the following DTD and called it sketchpadcopyright.dtd:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!ELEMENT copyright (currentversion)>
    <!ELEMENT currentversion (#PCDATA)>
    Then I wrote this XML file called sketchpadcopyright.xml:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/xsl" href="http://www.emmense.com/xmlfeed/sketchpadcopyright.xsl"?>
    <!DOCTYPE copyright SYSTEM "http://www.emmense.com/xmlfeed/sketchpadcopyright.dtd">
    <copyright>
    	<currentversion>0.1</currentversion>
    </copyright>
    And the following XSL stylesheet called sketchpadcopyright.xsl
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes" encoding="utf-8"
       doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
       doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" />
    <xsl:template match="/copyright">
    	<p>
    	<xsl:value-of select="currentversion"></xsl:value-of>
    	</p>
    </xsl:template>
    </xsl:stylesheet>
    and followed some code I found in one of KEvin's articles:
    PHP Code:
    <?php
    $xsltproc 
    xslt_create();
    $htmlxslt_process($xsltproc,'sketchpadcopyright.xml','sketchpadcopyright.xsl');
    if(!
    $html
        {
        exit(
    xslt_error($xsltproc));
        }
    xslt_free($xsltproc);
    echo 
    $html;
    ?>
    And I can't figure out why I'm getting this error:
    Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token) in /home/sketch/public_html/xmlfeed/sketchpadcopyright.php on line 3
    XML parser error 4: not well-formed (invalid token)
    (http://www.emmense.com/xmlfeed/sketchpadcopyright.php)

    What gives? :\
    Aaron Brazell
    Technosailor



  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's always XMLers around except when I need one.
    Aaron Brazell
    Technosailor



  3. #3
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One thing that isn't right is in the DTD file;

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!ELEMENT copyright (currentversion)>
    <!ELEMENT currentversion (#PCDATA)>
    There shouldn't be an XML processing instruction at the start so it should be;

    Code:
    <!ELEMENT copyright (currentversion)>
    <!ELEMENT currentversion (#PCDATA)>
    Not sure if that's your problem though.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •