Re: Mandatory attributes

Bruno Dumon <[email protected]> Tue, 06 Jan 2004 12:16:38 +0100
Newsgroups gmane.editors.pollo.devel
Organization Outerthought
Message-ID <[email protected]>
On Tue, 2004-01-06 at 11:52, Olivier POTONNIEE wrote:
> Hello
> 
> I'm using Pollo to edit XML document based on XML Schema grammars.
> I realizes Pollo source code could detect "mandatory" schema attributes (by displaying a '!' sign in editor pane), but this option was not activated. Does anybody knows why ? I reactivated it by modifying org.outerj.pollo.xmleditor.schema.MsvSchema.init() method, where "trackOptionalAttributes" was only set to true if the grammar was a DTD. I moved the assignment out of the 'if':
> 
>  trackOptionalAttributes = true;
>  if (type != null && type.equals("dtd"))
>  {
>      grammar =  DTDReader.parse(inputSource, new PolloMsvController());
>  }
>  else
>  {
>      // let MSV autodetect
>      grammar = GrammarLoader.loadSchema(inputSource, 
>                  new PolloMsvController(), saxParserFactory);
>  }
> 
> I'm pretty sure that doesn't work in all cases, in particular if
> grammar is null, or not a XML Schema. Is there a cleaner way to do it
> ?

It's currently not really possible to do this in a good way, since
internally Pollo translates the XML Schema to a simpler model, which is
not as powerful as XML Schema. It might however be possible to do
something meaningful for XML Schema without too much effort, since XML
Schema also has a simple relation between element names and the
attributes they have (though the same element name can be reused in
different contexts). In the general case of all schema languages
supported by MSV however, we cannot make that assumption since ie Relax
NG allows to apply content models to attributes as well, so a more
dynamic evaluation is needed there to decide whether an attribute is
required.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
[email protected]                          [email protected]



-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click