Subject: Re: [xsl] Error message saying doc is not well formed, has >1 top level element From: Michel Hendriksen <michel.hendriksen@xxxxxxxxx> Date: Wed, 4 May 2011 12:13:36 +0200 |
This will generate two <foo/> root elements which is not allowed/well formed as stated. But indeed the bar thing would also be bad... Looks like it can see that you are at the root and create two elements. If you do it in different templates it doesn't know. But then only the second time and only when standalone is on. Might be soemthing in the specs. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output standalone="yes"/> <xsl:template match="/"> <xsl:call-template name="tempa"/> <xsl:call-template name="tempa"/> </xsl:template> <xsl:template name="tempa"> <bar/> <bar/> </xsl:template> </xsl:stylesheet> Michel On Wed, May 4, 2011 at 11:27 AM, Wolfgang Laun <wolfgang.laun@xxxxxxxxx> wrote: > If this is of any help: I could reproduce a similar effect using > saxonhe9-2-0-2j.zip, by > setting > <xsl:output standalone="yes"/> <!-- or "no" --> > > and by coding this (full XSLT below): > > <xsl:template match="/"> > <xsl:call-template name="tempa"/> > <xsl:call-template name="tempa"/> > </xsl:template> > > <xsl:template name="tempa"> > <foo/> > <bar> > <xsl:apply-templates select="/*"/> > </bar> > > Only with the second call-template, it reports for the <foo/>line: > > Error on line 13 of strip.xsl: > SEPM0004: When 'standalone' or 'doctype-system' is specified, the > document must be > well-formed; but this document contains more than one top-level element > at xsl:call-template name="tempa" (file:/home/wlaun/XSLT/strip.xsl#8) > Transformation failed: Run-time errors were reported > > > If, however, the <foo/> line is omitted, there's no runtime error, > although the result isn't well-formed either! > <bar>...</bar><bar>...</bar> > > Variations are possible by calling two different templates, etc. > -W > > > <?xml version="1.0"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> > > <xsl:output standalone="yes" indent="yes"/> > > <xsl:template match="/"> > <xsl:call-template name="tempa"/> > <xsl:call-template name="tempa"/> > </xsl:template> > > <xsl:template name="tempa"> > <foo/> > <bar> > <xsl:apply-templates select="/*"/> > </bar> > </xsl:template> > > <xsl:template name="tempb"> > <bar/> > <foo> > <xsl:apply-templates select="/*"/> > </foo> > </xsl:template> > > <xsl:template match="@* | element() | comment() "> > <xsl:copy> > <xsl:apply-templates select="@* | node()"/> > </xsl:copy> > </xsl:template> > > </xsl:stylesheet> > > > > On 4 May 2011 11:10, Michael Kay <mike@xxxxxxxxxxxx> wrote: >> >> Two observations: >> >> (a) it doesn't look like a Saxon error message. That could be because the DITA toolkit is doing its own message formatting, or it could be because it comes from somewhere other than Saxon. It would be useful to know your processing pipeline, e.g. if the result tree is being serialized and then fed into an XML parser, the error could conceivably relate to the result document, and the point at which it is reported could be random because of output buffering. However, unless you're doing this, I wouldn't expect to see this error reported on a result document. >> >> (b) Apart from that, I fear there isn't enough information here for us to debug it for your. As my grandmother used to say, if you can't find something after trying hard, it's because you're looking in the wrong place. >> >> Michael Kay >> Saxonica >> >> On 04/05/2011 00:26, Steve Fogel wrote: >>> >>> 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)> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Error message saying doc , Wolfgang Laun | Thread | [xsl] Error message, doc not well f, Steve Fogel |
Re: [xsl] RE: Error message, doc no, Andrew Welch | Date | [xsl] Looking for a concise way of , John McGowan |
Month |