• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "MSXML and the DOCTYPE"

Collapse

  • NickFitz
    replied
    Originally posted by VectraMan View Post
    Huzzah!

    put_validateOnParse didn't work, but put_resolveExternals did. Thanks.

    Do you know if it can be made to format the output xml nicely? For testing purposes it'd be a lot easier if it didn't write everything out as one long line. I'm sure I've done that before, but I may be thinking about C#/.NET.
    If the DOM has been created from input that doesn't have newlines, it won't insert them. If you're creating the DOM by parsing a string, you'll have to insert newlines into the string. If you're doing it properly with createElement and so forth, you'll have to explicitly add the whitespace nodes with createTextNode.

    An easier approach is to use XSLT with an identity transform, and use <xslutput/>; you can also get it to generate the document type declaration for you:

    Code:
    <xsl:stylesheet  
      xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0">
    	
        <xsl:output 
          method="xml"
          encoding="UTF-8"
          omit-xml-declaration="yes"
          indent="yes"
          doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
          doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
    
    
        <xsl:template match="node()|@*">
            <xsl:copy>
                <xsl:apply-templates select="@*"/>
                <xsl:apply-templates/>
            </xsl:copy>
        </xsl:template>
    
    </xsl:stylesheet>

    Leave a comment:


  • dang65
    replied
    For HTML5 the DOCTYPE declaration is:

    <!DOCTYPE HTML>


    Happy days.

    Leave a comment:


  • VectraMan
    replied
    Huzzah!

    put_validateOnParse didn't work, but put_resolveExternals did. Thanks.

    Do you know if it can be made to format the output xml nicely? For testing purposes it'd be a lot easier if it didn't write everything out as one long line. I'm sure I've done that before, but I may be thinking about C#/.NET.

    Leave a comment:


  • doodab
    replied
    you could try setting validateOnParse to false, just in case it's deciding that empty HTML doc isn't valid as per the DTD?

    I suspect there is also a property to disable resolving external references i.e. the one in the DTD, not sure what it's called but you might need to make that false as well.

    Leave a comment:


  • VectraMan
    replied
    Yes I tried that, and it fails the loadXML there too.

    Leave a comment:


  • doodab
    replied
    There is a doctype property, but it's read only.

    Have you tried appending the root element in the string used when you create the thing in loadXML. This might be required so you have a "well formed" document.

    i.e.

    loadXml("<!DOCTYPE blah blah blah> <html></html>")

    Leave a comment:


  • VectraMan
    started a topic MSXML and the DOCTYPE

    MSXML and the DOCTYPE

    I'm writing something (in C++ on Windows) that outputs HTML, and uses the MSXML DOM to do it. This is easy enough. But there's one thing that has me stuck. At the top of any HTML you have some nonsense:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    And I can't figure out how to write that with the DOM. It's obviously not a regular XML element. I found some mention of a NODE_DOCUMENT_TYPE value, but passing that into createNode fails. The only other thing I can think to do is use loadXML with the above in a string when I create the DOM, and then add other things to it, but that fails too.

    Anyone know how to do this? It must be simple.

Working...
X