[xep-support] Re: line 1: Incorrect top element - should be 'root'

From: Kevin Brown <kevin_at_ADDRESS_REMOVED>
Date: Thu May 03 2018 - 11:23:44 PDT

After reading up a bit on Docbook, I have been away for a bit … it leads me to the question:

 

Which Docbook XSLs are you using to process the input? Are you using the v5 Docbook XSLs?

 

In reading the Docbook 5 documentation, it appears that the input is now in a default namespace and that is xmlns=http://docbook.org/ns/docbook.

So the v5 Docbook XSLs should account for this.

Which XSLs are you using?

 

Kevin

 

From: Xep-support [mailto:xep-support-bounces@renderx.com] On Behalf Of Kevin Brown
Sent: Thursday, May 03, 2018 11:14 AM
To: 'RenderX Community Support List' <xep-support@renderx.com>
Subject: [xep-support] Re: line 1: Incorrect top element - should be 'root'

 

NOTE: You can just create a simple bat/sh file to run Saxon.jar and input your XML and the XSL you are using.

Saxon.jar would be in the XEP installation directory … this is the same as you did with xsltproc.

Saxon (likely) is giving you the correct answer, there is no match. I do not see your Docbook XSLs but I suspect there is no namespace in them if they are vanilla.

 

Take this very simple example:

 

XML is:

<foo></foo>

 

XSL is:

<xsl:stylesheet xmlns:xsl=" <http://www.w3.org/1999/XSL/Transform> http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="foo">
        <bar/>
    </xsl:template>
</xsl:stylesheet>

 

Output is:

<bar/>

 

But change the input to:
<foo xmlns=" <http://docbook.org/ns/docbook> http://docbook.org/ns/docbook"></foo>

 

Output is nothing.

 

Why? Because <foo xmlns=" <http://docbook.org/ns/docbook> http://docbook.org/ns/docbook"></foo> is not matched by the template <xsl:template match="foo"><bar/></xsl:template>

 

There is no template matching foo in the namespace specified.

The stackoverflow article gives various guidance like changing the XSLs to 2.0 and adding that namespace or a whole sale rewrite of the template to add a prefixed namespace that equates to the default one in your XML.

The best solution is to figure out how/why the process producing the XML is adding that namespace, it should not really. Docbook XML AFAIK should have no namespace.

 

Kevin Brown

RenderX

 

 

From: Xep-support [ <mailto:xep-support-bounces@renderx.com> mailto:xep-support-bounces@renderx.com] On Behalf Of Kevin Brown
Sent: Thursday, May 03, 2018 10:11 AM
To: RenderX Community Support List < <mailto:xep-support@renderx.com> xep-support@renderx.com>
Subject: [xep-support] Re: line 1: Incorrect top element - should be 'root'

 

Please read this excellent post on Stackoverflow.

 

 

https://stackoverflow.com/questions/1344158/xslt-with-xml-source-that-has-a-default-namespace-set-to-xmlns

 

X4U is not doing anything except processing the results of Saxon transform which is nothing. The namespace is your XML does not match anything in the XSLT.

 

Kevin

 

 

Sent from my Verizon, Samsung Galaxy smartphone

 

-------- Original message --------

From: Stephen Taylor <stephen@kx.com <mailto:stephen@kx.com> >

Date: 5/3/18 1:08 AM (GMT-08:00)

To: XEP Support <xep-support@renderx.com <mailto:xep-support@renderx.com> >

Subject: [xep-support] Re: line 1: Incorrect top element - should be 'root'

 

That would be consistent with the following experiment. If I take the XML in its ‘working’ form and change the root element from article to book I get the same error message.

 

However, using xsltproc for the initial XSLT from XML (xmlns attribute included) produces valid FO XML:

 

<?xml version="1.0"?>

<fo:root xmlns:fo=" <http://www.w3.org/1999/XSL/Format> http://www.w3.org/1999/XSL/Format" xmlns:xlink=" <http://www.w3.org/1999/xlink> http://www.w3.org/1999/xlink"><fo:layout-master-set><fo:simple-page-master master-name="cover-page" page-width="210mm" …

 

which x4u renders happily to PDF.

 

That suggests the answer to my question Is there a better solution to this than removing the attribute? might be: Yes, use xsltproc for the initial transform to FO. Hard to imagine RenderX being satisfied with this answer, though.

 

Let me also draw your attention to the error report from x4u:

 

(document [system-id file:/Users/sjt/Projects/kx/tmp/aws/aws.xml]

  (validate

    [error] file:/Users/sjt/Projects/kx/tmp/aws/aws.xml: line 1: Incorrect top element - should be 'root'

    [validation total: 1 error]

    [error] com.renderx.xep.lib.FormatterException: Invalid XSL FO source 'file:/Users/sjt/Projects/kx/tmp/aws/aws.xml': 1 error found during validation

    [error] javax.xml.transform.TransformerException: com.renderx.xep.lib.FormatterException: Invalid XSL FO source 'file:/Users/sjt/Projects/kx/tmp/aws/aws.xml': 1 error found during validation

    [error] formatting failed

    [error] javax.xml.transform.TransformerException: com.renderx.xep.lib.FormatterException: Invalid XSL FO source 'file:/Users/sjt/Projects/kx/tmp/aws/aws.xml': 1 error found during validation

 

Formatting failed

 

We suppose the error to be in the FO produced by the initial transform. Above it is reported helpfully as Invalid XSL FO source but misleadingly as a validation error in line 1 of the original XML source.

 

That would of course be the place to point if no stylesheet were being applied. But x4u knows better.

 

What would I want x4u to do here? Write the intermediate FO to a temporary file and report the validation error in that. In this case the error seems to be in XEP’s XSLT processor, but if my XSL had produced invalid FO it would be helpful to see it.

 

Which leaves questions:

1. Why does x4u choke on the xmlns attribute?
2. Is there a better solution than (a) removing the attribute or (b) avoiding the XEP XSLT processor for the transformation to FO?

Stephen

 

 

Stephen Taylor | Librarian | Kx | +44 7713 400852 | <mailto:stephen@kx.com> stephen@kx.com

 

On 2 May 2018 at 20:00, <xep-support-request@renderx.com <mailto:xep-support-request@renderx.com> > wrote:

Send Xep-support mailing list submissions to
        xep-support@renderx.com <mailto:xep-support@renderx.com>

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.renderx.com/mailman/listinfo/xep-support
or, via email, send a message with subject or body 'help' to
        xep-support-request@renderx.com <mailto:xep-support-request@renderx.com>

You can reach the person managing the list at
        xep-support-owner@renderx.com <mailto:xep-support-owner@renderx.com>

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Xep-support digest..."

Today's Topics:

   1. Re: Xep-support Digest, Vol 86, Issue 1 (Kevin Brown)

----------------------------------------------------------------------

Message: 1
Date: Tue, 1 May 2018 14:44:21 -0700
From: "Kevin Brown" <kevin@renderx.com <mailto:kevin@renderx.com> >
To: "'RenderX Community Support List'" <xep-support@renderx.com <mailto:xep-support@renderx.com> >
Subject: [xep-support] Re: Xep-support Digest, Vol 86, Issue 1
Message-ID: <001801d3e195$92c447b0$b84cd710$@renderx.com <http://renderx.com> >
Content-Type: text/plain; charset="utf-8"

In other words:

<article xmlns=?http://docbook.org/ns/docbook?>

Does not match:

<article>

Kevin

From: Xep-support [mailto:xep-support-bounces@renderx.com <mailto:xep-support-bounces@renderx.com> ] On Behalf Of Stephen Taylor
Sent: Tuesday, May 01, 2018 2:14 PM
To: XEP Support <xep-support@renderx.com <mailto:xep-support@renderx.com> >
Subject: [xep-support] Re: Xep-support Digest, Vol 86, Issue 1

Sorry I did not make myself more clear.

x4u renders my XML and XSL as a PDF ? 70 pages of beautiful typography ? provided I remove the xmlns attribute from the XML root element, which is, as you note, article.

The xmlns attribute was written by Pandoc <http://pandoc.org> as DocBook 5 <http://docbook.org> XML output. It looks correct to me. DocBook is an XML application that will be familiar to many XEP users. So I?m wondering why x4u would report the attribute as a validation error in the XML.

My question stands: is there a better solution to this than removing the attribute?

_______________________________________________
(*) To unsubscribe, please visit http://lists.renderx.com/mailman/options/xep-support
(*) By using the Service, you expressly agree to these Terms of Service http://w
ww.renderx.com/terms-of-service.html
Received on Thu May 3 11:22:13 2018

This archive was generated by hypermail 2.1.8 : Thu May 03 2018 - 11:22:18 PDT