Varying schemas and autocomplete problems

Having trouble installing Oxygen? Got a bug to report? Post it all here.
napthali
Posts: 2
Joined: Wed Dec 06, 2006 8:53 pm

Varying schemas and autocomplete problems

Post by napthali »

I'm very new to oxygen, to it's quite possible that I'm simply misusing a feature, here.

When I use a Relax NG schema, oxygen doesn't properly add required attributes and elements with the autocomplete function. If I take that schema and make it into a W3C XML Schema (using Trang), then it properly autocompletes, but no longer validates content defined as xsd:integer and the like.

It's an unfortunate tradeoff to make, as I'd very much like to have both features so my engineers don't have to worry about their data being proper and complete.

Any advice or thoughts on the matter?

(A secondary question... is there an attribute-level equivalent of the "Go after Next Tag" shortcut?)
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Varying schemas and autocomplete problems

Post by sorin_ristache »

Hello,
napthali wrote:When I use a Relax NG schema, oxygen doesn't properly add required attributes and elements with the autocomplete function.
I think you want to insert automatically child elements and child attributes that are not defined as optional (the oneOrMore pattern, attributes that are not enclosed by the optional pattern, etc) when their parent element is inserted in the edited document by the content completion assistant. Yes, that is a difference between content completion based on an XML Schema vs. a Relax NG schema. It is an enhancement for content completion based on Relax NG schemas that we will consider for a future version of oXygen.
napthali wrote:is there an attribute-level equivalent of the "Go after Next Tag" shortcut?)
There is no such shortcut action. Using the Ctrl + left arrow / right arrow shortcut two or three times should move the cursor to the next attribute. A "Go after Next Attribute" action would do just that: move the cursor as you would move it two times or three times with the Ctrl + Arrow action.


Regards,
Sorin
napthali
Posts: 2
Joined: Wed Dec 06, 2006 8:53 pm

Re: Varying schemas and autocomplete problems

Post by napthali »

sorin wrote:
I think you want to insert automatically child elements and child attributes that are not defined as optional (the oneOrMore pattern, attributes that are not enclosed by the optional pattern, etc) when their parent element is inserted in the edited document by the content completion assistant. Yes, that is a difference between content completion based on an XML Schema vs. a Relax NG schema. It is an enhancement for content completion based on Relax NG schemas that we will consider for a future version of oXygen.
Ah, good clarification. I guess I assumed that oXygen translated all schema types to some kind of universal internal representation. Good to know it's not a bug, but a "yet-to-be-implemented." :-)

Do W3C Schemas not allow type validation (i.e. xsd:integer)?

Thanks for your help!
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Varying schemas and autocomplete problems

Post by sorin_ristache »

napthali wrote:Do W3C Schemas not allow type validation (i.e. xsd:integer)?
Yes, W3C Schema allows type validation. If your XML document is validated against an XML Schema that specifies the xsd:integer type for the value of an element or attribute then that value is checked to be an integer.


Regards,
Sorin
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

Re: Varying schemas and autocomplete problems

Post by anayram »

napthali wrote: I think you want to insert automatically child elements and child attributes that are not defined as optional (the oneOrMore pattern, attributes that are not enclosed by the optional pattern, etc) when their parent element is inserted in the edited document by the content completion assistant. Yes, that is a difference between content completion based on an XML Schema vs. a Relax NG schema. It is an enhancement for content completion based on Relax NG schemas that we will consider for a future version of oXygen.
We are also working with Relax NG schemas. That would be a great enhancement: when inserting a new element, we would like non-optional child elements and non-optional attributes to be inserted automatically. The content completion assistant is not very useful for the academics working on our project.

Has this enhancement been implemented? Thanks!
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Varying schemas and autocomplete problems

Post by sorin_ristache »

Hello,

That is supported in version 11.0 which you can download from the Download page. If a RELAX NG schema declares an element that is enclosed in oneOrMore or an attribute is not optional then the element or the attribute are generated by the New dialog in the initial XML document based on that RELAX NG schema.


Regards,
Sorin
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

Re: Varying schemas and autocomplete problems

Post by anayram »

Hi Sorin,

Thanks for your time.

Here are two things that would be really nice to have, and which would be great additions to Oxygen's usability by content authors:

[*]Autocomplete to include required values: In the New dialog (initial XML document) it would be great if Oxygen also added automatically required values / fixed values to such non-optional attributes. When I create a new XML document using a RelaxNG schema, all required elements and attributes are added, but not required values. I have enabled first "add choice particle" in the content completion panel, but this doesn't seem to help.

[*]Autocomplete for new elements during edit: automatic content completion for editing a document; for example, when adding a new element <poem> which requires oneOrMore <verse>, Oxygen to automatically add a <verse> element.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: Varying schemas and autocomplete problems

Post by george »

1. Relax NG does not have a notion of default or fixed attribute value in the sense of DTD or XML Schema because it does not change the XML, it just provides validation. You can surely check the values of an attribute against a list if values.
Maybe what you want here is more like the XML instance generator that we have for XML Schema? See "Tools->Generate Sample XML Files".

2. If insert required content is enabled in options and poem contains one or more verse elements then oXygen will automatically insert one verse element when you insert poem. Just tried that with the schema below

Code: Select all


<grammar xmlns="http://relaxng.org/ns/structure/1.0" 
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
<start>
<element name="root">
<element name="poem">
<oneOrMore>
<element name="verse">
<text/>
</element>
</oneOrMore>
</element>
</element>
</start>
</grammar>
Best Regards,
George
George Cristian Bina
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

Re: Varying schemas and autocomplete problems

Post by anayram »

george wrote:1. Relax NG does not have a notion of default or fixed attribute value in the sense of DTD or XML Schema because it does not change the XML, it just provides validation. You can surely check the values of an attribute against a list if values.
Maybe what you want here is more like the XML instance generator that we have for XML Schema? See "Tools->Generate Sample XML Files".
Thanks, I understand now. Then, should I expect the "add first choice particle" option to work? I thought that, given a list of possible values, Oxygen would pick the first choice in the list and insert it automatically.

About your question on whether what we need is something similar to the XML instance generator: if I understand correctly, what this does is creating a sample XML file based on an XML schema (W3C in this case), but what we need is support during the edit process.

For example: suppose there is an element <QUOTE> (which requires the non-optional attribute DIRECT and a value of either "Y" or "N"); during content creation (not during new XML file creation). From author mode, by inserting the element <QUOTE> I would automatically get:

Code: Select all

<QUOTE DIRECT="Y"></QUOTE>
If I want to choose "N" I would do that later, but if I need "Y", I would be confident the attribute has already been added automatically.
george wrote:2. If insert required content is enabled in options and poem contains one or more verse elements then oXygen will automatically insert one verse element when you insert poem.
Does such content insertion happens when creating a new XML document (not during content edit, which is what wee would need)? Please correct if I am wrong.

Thank you!
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: Varying schemas and autocomplete problems

Post by george »

Looking more into this I found the a:defaultValue annotation in Relax NG that can be used to provide a default value to be inserted automatically in the document as you suggested, you can find details here
http://www.oasis-open.org/committees/re ... ault-value

The required element as in the example from my previous post is added by oXygen both when editing and when creating a new element based on that schema.

Best Regards,
George
George Cristian Bina
glorieux
Posts: 1
Joined: Tue Dec 11, 2012 1:26 pm

Re: Varying schemas and autocomplete problems

Post by glorieux »

Hi George,

Sorry to answer to an old thread, but I'm not sure to understand why you answered "no" for forced values in attribute with Relax-NG. I can imagine that we have not exactly the same concepts that in DTDs, but some desired behaviors could be compared.

Imagine this real life Relax-NG pattern

<element name="availability">
<attribute name="status">
<value>restricted</value>
</attribute>
<ref name="p"/>
</element>

The generated content by Oxygen (14.1 2012101909) is

<availability status="">
<p></p>
</availability>

The generated content is not valid because the @status attribute value is forced to "restricted". Value is correctly suggested (after delete and rewrite a quote, I understand how tricky could be such events handling).

This is not the best XML practice we may like, but very common in specific profiles from generic schemas like TEI, docbook or EAD.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: Varying schemas and autocomplete problems

Post by george »

Hi,

In general there are more value patterns there... but indeed it will be interesting if we can detect the case with only one value pattern and use that like a fixed value for that attribute.
Please note that you do not need to delete the quote and type it again to trigger the content completion - you can trigger the content completion on request with CTRL+Space. There is also an additional action with configurable shortcut called "Start Content Completion) with the default shortcut "Alt+CTRL+/" or, for Mac, "Alt+CMD+/".

Hope this helps,
George
George Cristian Bina
Post Reply