[xsl] Error message saying doc is not well formed, has >1 top level element

Subject: [xsl] Error message saying doc is not well formed, has >1 top level element
From: Steve Fogel <STEVE.FOGEL@xxxxxxxxxx>
Date: Tue, 3 May 2011 16:26:59 -0700 (PDT)
Hi, all.

I'm getting an error message from Saxon 9.1.0.5J (from the DITA Open Toolkit)
that I don't understand. It's complaining about a template that has worked
fine in another situation and now, when plugged into a new set of templates,
is generating the following message:

(path)/infodev2htmtoc.xsl:86: Fatal Error! When 'standalone' or
'doctype-system' is specified, the document must be well-formed; but this
document contains more than one top-level element"

Odd thing is, in addition to the fact that this stylesheet produced
well-formed output when used elsewhere, line 86 seems to have nothing to do
with anything.

Can anyone suggest what might be happening? It's a long stylesheet, and the
first part of the code follows. Line 86 is indicated by preceding asterisks
(***). The entry point is the template "generate-toc". There are a vast number
of <xsl:output> declarations throughout the code that includes this
stylesheet, but this template outputs the main result tree, and the only
output declarations that mention doctype-system are named ones, AFAIK.

Thanks.

Steve
------------

<?xml version="1.0" encoding="UTF-8"?>
<!-- ********** Oracle customizations to XHTML TOC page Copyright (c) Oracle
Corporation
     by Steve Fogel and Colin McGregor *********** -->

<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml";
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:java="org.dita.dost.util.StringUtils"
    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    exclude-result-prefixes="java xs">

        <!-- Following commented out lines required when this file used with
HTML1 -->
<!--    <xsl:output method="html" indent="yes" encoding="UTF-8"
omit-xml-declaration="yes"/>
        <xsl:include href="id_headHeaderFooter.xsl"/>   -->

  <!-- params added for index link creation. can be passed in via xhtmlindex
plugin cmcgrego 3/17/2011 -->
  <xsl:param name="INDEXFILEBASE" select="'index'"/> <!-- base name for index
file, without the ext. can be set in ant -->
  <xsl:param name="INDEXOUTDIR" select="'id_topic/'" /> <!-- index output
directory relative to toc.htm -->

    <!-- Setup the HTML wrapper for the table of contents -->
    <xsl:template name="generate-toc">
        <xsl:message>****** Generating DARB-like XHTML TOC
********</xsl:message>
        <html xml:lang="en" lang="en"><xsl:value-of select="$newline"/>
            <head><xsl:value-of select="$newline"/>
                <!-- initial meta information -->
                <xsl:call-template name="generateCssLinks"/>  <!-- Generate
links to CSS files -->
                <xsl:call-template name="generateMapTitle"/> <!-- Generate the
<title> element -->
                <xsl:call-template name="gen-user-head" />    <!-- include
user's XSL HEAD processing here -->
            </head><xsl:value-of select="$newline"/>

            <body>
<!--                <xsl:if test="string-length($OUTPUTCLASS) &gt; 0">
                    <xsl:attribute name="class">
                        <xsl:value-of select="$OUTPUTCLASS"/>
                    </xsl:attribute>
                </xsl:if>-->
                <xsl:value-of select="$newline"/>
                <xsl:apply-templates/>
            </body><xsl:value-of select="$newline"/>
        </html>
    </xsl:template>

    <xsl:template name="generateMapTitle">
        <!-- Title processing - special handling for short descriptions -->
        <xsl:if test="/*[contains(@class,' map/map ')]">
            <title>
                <xsl:call-template name="getString">
                    <xsl:with-param name="stringName" select="'TOC'"/> <!--
"Table of Contents" -->
                </xsl:call-template>
            </title>
            <xsl:value-of select="$newline"/>
        </xsl:if>
    </xsl:template>


    <!-- Generate link to CSS  -->
    <!-- Can't link to commonltr.css or commonrtl.css because we don't know
what language the map is in. -->
    <!-- **** Oracle: add link to blafdoc.css -->
    <xsl:template name="generateCssLinks">
        <xsl:variable name="urltest">
            <xsl:call-template name="url-string">
                <xsl:with-param name="urltext">
                    <xsl:value-of select="concat($CSSPATH,$CSS)"/>
                </xsl:with-param>
            </xsl:call-template>
        </xsl:variable>
        <xsl:if test="string-length($CSS)>0">
            <xsl:choose>
                <xsl:when test="$urltest='url'">
                    <link rel="stylesheet" type="text/css"
href="{$CSSPATH}{$CSS}" />
                </xsl:when>
                <xsl:otherwise>
                    <link rel="stylesheet" type="text/css"
href="{$PATH2PROJ}{$CSSPATH}{$CSS}" />
                </xsl:otherwise>
            </xsl:choose><xsl:value-of select="$newline"/>
        </xsl:if>
        <link rel="stylesheet" href="../../dcommon/css/blafdoc.css"
title="Oracle BLAFDoc"
            type="text/css" /><xsl:value-of select="$newline"/>
    </xsl:template>


  <!-- Process the map -->
  <xsl:template match="/*[contains(@class, ' map/map ')]">
    <xsl:param name="pathFromMaplist"/>
    <xsl:if test=".//*[contains(@class, ' map/topicref
')][not(@toc='no')][not(@processing-role='resource-only')]">
      <xsl:call-template name="gen-user-header"/>
            <div class="ind">
***line 86** <xsl:value-of select="$newline"/>
                <h1 class="toc">
                    <xsl:call-template name="getString">
                        <xsl:with-param name="stringName"
select="'Contents'"/>
                    </xsl:call-template>
                </h1>
                <xsl:value-of select="$newline"/>

                <!-- Insert title/copyright page  -->
                <xsl:call-template name="generateTitleLink" />

                <!-- Topics -->
                <xsl:apply-templates select="*[contains(@class, ' map/topicref
')]">
                    <xsl:with-param name="pathFromMaplist"
select="$pathFromMaplist"/>
                </xsl:apply-templates>

                <!--Call-template Insertion here for generating index link.
cmcgrego 3/17/2011 -->
                <xsl:call-template name="generateIndexLink"/>
            </div>
      <xsl:value-of select="$newline"/>
      <xsl:call-template name="gen-user-footer"/>
    </xsl:if>
  </xsl:template>

... more...

Current Thread