DocBook html-namespace validation failes

Oxygen general issues.
Matthias
Posts: 9
Joined: Wed Apr 01, 2009 1:19 pm

DocBook html-namespace validation failes

Post by Matthias »

Hello,

I tried to use the html:-nodes for the first time, but my document does not get validated anymore in Oxygen 9.3.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng" type="xml"?>
<part
version="5.0"
xml:id="test"
xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:html="http://www.w3.org/1999/xhtml">
<title>test</title>
<partintro>
<para>blabla</para>
</partintro>

<chapter
xml:id="test1">
<title>test1</title>
<para>blablabla</para>

<sect1
xml:id="test1-1">
<title>html:form</title>
<html:form action="http://www.example.org/cgi-bin/dosomething">
<para>id: <html:input name="id"/></para>
<para>url: <html:input name="url"/></para>
<para>title: <html:input name="title"/></para>
<para>excerpt: <html:input name="excerpt"/></para>
<para>blogname: <html:input name="blog_name"/></para>
<html:input type="submit"/>
</html:form>
</sect1>

</chapter>

</part>
All the lines including a <html:>-Element are underlined red and Oxygen tells me:
Description: unknown element "input" from namespace "http://www.w3.org/1999/xhtml"


When I create a new xhtml-document in Oxygen, there is no validation problem with the same namespace.

Can somebody give me a tip what I am doing wrong?

Thank you very much.

Kind Regards

Matthias
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: DocBook html-namespace validation failes

Post by sorin_ristache »

Hello,

The Docbook schema does not include by default a schema for XHTML. You have to combine the RELAX NG schema for Docbook 5 with a XHTML schema. For example you can create a NVDL schema that allows both namespaces or you can modify the Docbook 5 schema.


Regards,
Sorin
Matthias
Posts: 9
Joined: Wed Apr 01, 2009 1:19 pm

Re: DocBook html-namespace validation failes

Post by Matthias »

Hello,

thank you for the reply. As I have not worked with schemas yet (except specifying them with the <?oxygen RNGSchema-tag), is there a combined DocBok/Xhtml schema available for download somewhere? My first google-search did not turn up any.

Otherwise I have to learn relax ng :-)

Cheers

Matthias
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: DocBook html-namespace validation failes

Post by george »

Hi,

Here it is an NVDL script that validates the DocBook excluding the XHTML content. The XHTML content is allowed but it is not validated against a schema, if you want to do that then the script needs a couple of more changes:

Code: Select all


<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" startMode="docbook">
<mode name="docbook">
<namespace ns="http://docbook.org/ns/docbook">
<validate schema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng"
useMode="allowXHTML"/>
</namespace>
</mode>
<mode name="allowXHTML">
<namespace ns="http://www.w3.org/1999/xhtml">
<unwrap useMode="attachDocBook"/>
<allow useMode="allowAnything"/>
</namespace>
</mode>
<mode name="attachDocBook">
<namespace ns="http://docbook.org/ns/docbook">
<attach useMode="allowXHTML"/>
</namespace>
</mode>
<mode name="allowAnything">
<anyNamespace>
<allow/>
</anyNamespace>
</mode>
</rules>
Best Regards,
George
George Cristian Bina
Matthias
Posts: 9
Joined: Wed Apr 01, 2009 1:19 pm

Re: DocBook html-namespace validation failes

Post by Matthias »

Hello George,

thank you very much, that really got me started and my document is now properly validated.

I have a further question though. You created the allowXHTML mode as follows:

Code: Select all

<mode
name="allowXHTML">
<namespace
ns="http://www.w3.org/1999/xhtml">
<unwrap
useMode="attachDocBook" />
<allow
useMode="allowAnything" />
</namespace>
</mode>
That led to an error with the following part of my document, as DokBook elements are forbidden:

Code: Select all


                  <html:form
action="http://www.example.org/cgi-bin/dosomething">
<html:input
name="id" />
<para>url: <html:input
name="url" /></para>
<para><html:input
type="submit" /></para>
</html:form>
And only allowed:

Code: Select all


                <html:form
action="http://www.example.org/cgi-bin/dosomething">
<html:input
name="id" />
<html:p>url: <html:input
name="url" /></p>
<html:p><html:input
type="submit" /></p>
</html:form>
Whithout the

Code: Select all

<unwrap
useMode="attachDocBook" />
I can use DocBook elements in the html:form.

Why did you not allow DocBook Elements to be used in the html-part? Has that some major drawbacks, is considered bad form or whatever?

Thank you very much.

Kind Regards

Matthias
Matthias
Posts: 9
Joined: Wed Apr 01, 2009 1:19 pm

Re: DocBook html-namespace validation failes

Post by Matthias »

Hello again,

I tried to modify the NVDL to also validate against the xhtml-rng, but both versions:
1)

Code: Select all

<rules
startMode="docbook"
xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
<mode
name="docbook">
<namespace
ns="http://docbook.org/ns/docbook">
<validate
schema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng"
useMode="allowXHTML" />
</namespace>
</mode>
<mode
name="allowXHTML">
<namespace
ns="http://www.w3.org/1999/xhtml">
<unwrap
useMode="attachDocBook" />
<validate
schema="file:/L:/schemas/xhtml/xhtml-strict.rng"
useMode="allowAnything" />
</namespace>
</mode>
<mode
name="attachDocBook">
<namespace
ns="http://docbook.org/ns/docbook">
<attach
useMode="allowXHTML" />
</namespace>
</mode>
<mode
name="allowAnything">
<anyNamespace>
<allow />
</anyNamespace>
</mode>
</rules>
2)

Code: Select all

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="init">
<mode name="init">
<namespace ns="http://docbook.org/ns/docbook">
<validate schema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng">
<mode>
<namespace ns="http://www.w3.org/1999/xhtml">
<validate schema="file:/L:/schemas/xhtml/xhtml-strict.rng"/>
</namespace>
</mode>
</validate>
</namespace>
</mode>
</rules>
result in Oxygen telling me Description: element "form" from namespace "http://www.w3.org/1999/xhtml" not allowed in this context
with the following xml:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<?oxygen NVDLSchema="file:/L:/schemas/schema_DocBook_allow_and_validate_Xhtml.nvdl"?>
<chapter
version="5.0"
xml:id="test"
xmlns="http://docbook.org/ns/docbook"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>nvdl-test</title>

<sect1
xml:id="Kontierung_Kontenplan_Abfrage">
<title>xhtml-part</title>
<para>test</para>
<html:form
action="http://www.example.org/cgi-bin/dosomething">
<html:p>
<html:input
name="id" />
</html:p>
<html:p>
<html:input
type="submit" />
</html:p>
</html:form>
</sect1>
</chapter>
Can somebody again please help me out?

Thank you very much.

Kind Regards

Matthias
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: DocBook html-namespace validation failes

Post by george »

The xhtml-strict.rng schema allows only html as start element so it cannot validate the XHTML from your sample because that starts with form. To be able to validate that you need a schema that allows form as start element. For example you can create a schema with the following content:

xhtml-strict-open.rng

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

<include href="xhtml-strict.rng"/>

<start combine="choice">
<ref name="form"/>
</start>
</grammar>
that adds form as a possible start element.

Then the following NVDL script will get all the DocBook and validate that against the DocBook schema and all the XHTML fragments and validate them against the xhtml-strict-open.rng schema - note that you may need to edit the xhtml-strict-open.rng location in the NVDL script to match your actual location:

Code: Select all


<rules startMode="docbook" xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">


<mode name="docbook">
<namespace ns="http://docbook.org/ns/docbook">
<validate schema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng"
useMode="validateXHTMLandAttachDocBook"/>
</namespace>
</mode>

<mode name="validateXHTMLandAttachDocBook">
<namespace ns="http://www.w3.org/1999/xhtml">
<!-- ignore the XHTML section and process descendat sections with the attachDocBook mode
that will attach all the descendant DocBook sections -->
<unwrap useMode="attachDocBook"/>
<!-- start a validate action on the current section with all the descendant XHTML sections attached -->
<validate schema="relaxng/xhtml-strict-open.rng" useMode="attachXHTML"/>
</namespace>
</mode>

<mode name="attachDocBook">
<namespace ns="http://docbook.org/ns/docbook">
<attach/>
</namespace>
<anyNamespace>
<unwrap/>
</anyNamespace>
</mode>

<mode name="attachXHTML">
<namespace ns="http://www.w3.org/1999/xhtml">
<attach/>
</namespace>
<anyNamespace>
<unwrap/>
</anyNamespace>
</mode>
</rules>
Best Regards,
George
George Cristian Bina
Matthias
Posts: 9
Joined: Wed Apr 01, 2009 1:19 pm

Re: DocBook html-namespace validation failes

Post by Matthias »

Hello George,

thank you very much, this works perfectly! Thank you for your effort!

I did not thought of the fact that xhtml anticipates a complete xhtml-document to follow, but now that I think of it it is clear.

This nvd-scripting opened a whole new world for me, thank you again.

Regards

Matthias
Post Reply