[oXygen-user] XHTML 2 validation, revisited

George Cristian Bina
Fri Jun 8 03:39:24 CDT 2007


Hi Paul,

Open the http://www.w3.org/People/mimasa/test/schemas/rng/xhtml2.rng 
schema in oXygen and switch to logical model view. Then expand Start -- 
html -- html.content -- body.
Then you can see that body contains some attributes then one or more 
from a choice of
(
    XHTML elements,
    a *sequence* of
    [choice of (input,...), optional(...), group, switch, repeat]
)

So, if you have input then you must have that followed by group, switch 
and repeat.

This is caused from the way the Misc.class pattern is defined:

<define name="Misc.class" combine="choice">
   <ref name="XFORMS.Form.Controls"/>
   <ref name="XFORMS.Actions"/>
   <ref name="XFORMS.Group"/>
   <ref name="XFORMS.Switch"/>
   <ref name="XFORMS.Repeat"/>
</define>

As you have an implicit group pattern that combines the ref patterns.

What you probably want is a choice of those pattern, eventually inside a 
zeroOrMore or an oneOrMore pattern.

<define name="Misc.class" combine="choice">
   <choice>
       <ref name="XFORMS.Form.Controls"/>
       <ref name="XFORMS.Actions"/>
       <ref name="XFORMS.Group"/>
       <ref name="XFORMS.Switch"/>
       <ref name="XFORMS.Repeat"/>
   </choice>
</define>

If you change the schema xhtml2.rng schema as above the document will be 
validated without problems.

An easy way to test is to make the change in the schema, save it locally 
and add an 
xml:base="http://www.w3.org/People/mimasa/test/schemas/rng/xhtml2.rng" 
in the root element to have the includes properly resolved then use the 
local schema in your documents.

But what I would recommend will be to take a look also at NVDL, see the 
samples/nvdl from oXygen for a sample that shows usage of XHTML plus XForms.

I was about to forget: you have the problem with implicit group patterns 
in Relax NG probably on more patterns, just below the Misc.class I see

<define name="XFORMS.UI.Inline.class" combine="choice">
   <ref name="Text.class"/>
   <ref name="Misc.class"/>
</define>

so I believe all the schema need to be revised with the implicit group 
patterns in mind.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Paul Everitt wrote:
> 
> 13 months ago I posted here then rng-users for help on XHTML 2 
> validation using the RNG schemas. I am revisiting the problem and 
> running into a snap that has me quite perplexed.
> 
> I'm using the experimental schemas located here:
> 
>   http://www.w3.org/People/mimasa/test/schemas/rng/xhtml2.rng
> 
> Everything is fine when I don't use any form controls:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <?oxygen
> RNGSchema="http://www.w3.org/People/mimasa/test/schemas/rng/xhtml2.rng"
> type="xml"?>
> <html xmlns="http://www.w3.org/2002/06/xhtml2/">
> <head>
> <title>Hello World</title>
> </head>
> <body>
> <p>Hello World</p>
> </body>
> </html>
> 
> This validates in both oXygen 8.2 and xmllint. However, any attempt to 
> introduce a form element leaves me in an "Unfinished element" status on 
> the body:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <?oxygen
> RNGSchema="http://www.w3.org/People/mimasa/test/schemas/rng/xhtml2.rng"
> type="xml"?>
> <html xmlns="http://www.w3.org/2002/06/xhtml2/"
> xmlns:q="http://foo.org">
> <head>
> <title>Hello World</title>
> <model>
> <instance>
> <q:x/>
> </instance>
> </model>
> </head>
> <body>
> <input ref="q:x">
> <label>x</label>
> </input>
> </body>
> </html>
> 
> oXygen 8.2 reports "E [oNVDL] unfinished element" on the closing 
> </body>. xmllint reports:
> 
> Untitled4.xml:13: element input: Relax-NG validity
> error : Element body has extra content: input
> 
> Wrapping the <input> in a <div> simply moves the error to the <div>. I 
> spent a couple of hours hacking around in the pile of schemas, trying to 
> figure out what was missing.
> 
> I downloaded the schemas from the July 2006 working draft of XHTML 2:
> 
> http://www.w3.org/TR/xhtml2/xhtml2.html
> 
> But these don't even work out-of-the-box. I supplied the 2 missing RNGs 
> (xforms.rng and xforms-nons-11.rng) and wound up with the same error.
> 
> I'd be interested to find an XHTML 2 example that includes form elements 
> *and* validates against some known schema, RNG or otherwise.
> 
> And yes, I know XHTML2 doesn't work in browsers. This is for the early 
> stage of an XProc pipeline, with a later stage that converts to XHTML 1.
> 
> --Paul
> _______________________________________________
> oXygen-user mailing list
> 
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user



More information about the oXygen-user mailing list