Page 1 of 1

Create empty XML as specced (create additional content)

Posted: Sat Apr 21, 2007 10:22 pm
by amix
I want to create a template of an Atom feed, that contains all the elements, that are possible. I thought I could do this by selecting "create additional content" in the New-File wizard.

The Atom is specced via a RelanxNG/compact and this did not allow for creation of additional content. So I transformed that into an XML Schema, using oXygen. When I select "feed" as root element I get only author and feed elements, but not all the other possibilities.

Any ideas ? I thought it would be possible to create an empty template with all elements possible this way ?

Thanks.

Posted: Mon Apr 23, 2007 10:33 am
by sorin_ristache
Hello,

The generated elements depend on your schema. As you can see in the Create an XML document dialog in the XML Schema tab only optional content and first choice particles can be generated in the new document with the File -> New action. Did you check the two checkboxes and there are first choice particles or optional content that are not generated in the new document?

If you want a complete XML document you can use the XML document instance generator available from menu Tools -> Generate Sample XML Files.


Regards,
Sorin

Posted: Mon Apr 23, 2007 11:05 am
by sorin_ristache
Hello,

If you need to generate a document from the same schema many times you can generate the document only once and then add it to the list of document templates from menu File -> Add to Templates. When you need a new document just generate it from the template using File -> New from Templates.


Regards,
Sorin

Posted: Sat Apr 28, 2007 10:01 pm
by amix
Thanks.

Yes, I checked the two boxes for additional content. I was trying to draw a full Atom XML template from the Schema. I chose 'feed' as root element.

I still run into problems, using the "Create Sample XML Documents" but maybe there is no way around them.

If I create it with the "additional content" options on, I get a similarily short result (ie not all tags are available in the sample), though I have <ANY> - <ANY> set and both checkboxes (additional content, etc.) checked.

If I chose the "add additional tags in comments" option, I get a very verbose file, that seems to include all and everything. But this file requires too much editing to work with.

Also it seems to be impossible to leave the default-namespace empty, like in

Code: Select all

<atom:link />
<html:br />
should really become

Code: Select all

<link />
<html:br />
Therefore I tried to leave the edit dialog for the renaming of the namespaces (I got ns1 and ns2) empty for ns1, but the dialog would not accept an empty string.

Posted: Mon Apr 30, 2007 3:29 pm
by sorin_ristache
Hello,
amix wrote:If I create it with the "additional content" options on, I get a similarily short result (ie not all tags are available in the sample), though I have <ANY> - <ANY> set and both checkboxes (additional content, etc.) checked.

If I chose the "add additional tags in comments" option, I get a very verbose file, that seems to include all and everything. But this file requires too much editing to work with.
If I understand correctly with the options for optional elements the generated XML instance is too short and if you add also the option to generate the rest of the options as comments the instance is too long. In that case you can try with the other choice strategy for selecting an alternative inside an <xs:choice> and <xs:substitutionGroup>, that is Random instead of First. If this is also too short then I recommend generating one XML instance with the option to generate the rest of the options as comments, edit this instance and remove unnecessary options until you get an acceptable template and then add this template to the list of oXygen XML templates using the action File -> Add to Templates. After that use the template from File -> New from Templates for every new Atom feed document that you will create.
amix wrote:Also it seems to be impossible to leave the default-namespace empty, like in

Code: Select all

<atom:link />
<html:br />
should really become

Code: Select all

<link />
<html:br />
Therefore I tried to leave the edit dialog for the renaming of the namespaces (I got ns1 and ns2) empty for ns1, but the dialog would not accept an empty string.
No, it is not impossible. Just select the namespace that you want to be used without prefix in the Default Namespace combo box of the dialog for generating XML instances.


Regards,
Sorin

Posted: Sun May 20, 2007 8:43 pm
by amix
Would it make sense to allow for optional content to be created without the comments ?

Posted: Mon May 21, 2007 11:09 am
by sorin_ristache
The options generated as comment are the ones defined in the same choice element or in the same substitution group as the option generated before the comment. They cannot be generated without the comments because if the XML instance contains more than one option of a choice element that instance is not valid against the XML Schema used to generate it.


Regards,
Sorin

Posted: Sat May 26, 2007 7:56 pm
by amix
Ah, okay, I understand.