Home > Mobile >  The element 'xsl:stylesheet' is used but not declared in the DTD/Schema
The element 'xsl:stylesheet' is used but not declared in the DTD/Schema

Time:09-30

I'm trying to convert an XSL-FO document to HTML using the "fo2html.xsl" file from RenderX. That was the suggestion from this StackOverflow post: Converting XSL-FO to HTML

I'm using the load() method, and it works on everything up until loading the "fo2html.xsl" file.

            hr = pXMLDoc->load(vSource, &vbResult);

The IXMLDOMParseError object is telling me that it's line 24 of the XML that is the problem.

<!DOCTYPE xsl:stylesheet [
  <!ENTITY anchor "<xsl:apply-templates select='@id' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'/>">
  <!ENTITY add-style "<xsl:call-template name='add-style-attribute' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'/>">
]>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                exclude-result-prefixes="fo">

Line 24 is the last line of the above XML. The error source is returning exclude-result-prefixes="fo">, and the reason is:

The element 'xsl:stylesheet' is used but not declared in the DTD/Schema

I've tried pDoc2->put_resolveExternals(VARIANT_TRUE); and pDoc2->setProperty(L"ProhibitDTD", v);, but neither changed anything.

What do I need to do to load "fo2html.xsl" using MSXML?

Thanks!

CodePudding user response:

You could try adding an XML declaration (see https://www.w3.org/TR/REC-xml/#sec-prolog-dtd) that indicates that the document is standalone:

<?xml version="1.0" standalone="yes" ?>

Alternatively, you might need to expand the entities yourself and get rid of the DOCTYPE declaration so there's no schema in the file.

  • Related