Bug 193205 - [Cheatsheet][Builders][Simple] Define a builder to validate underlying XML file well-formedness
Summary: [Cheatsheet][Builders][Simple] Define a builder to validate underlying XML fi...
Status: NEW
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-18 17:25 EDT by Mike Pawlowski CLA
Modified: 2018-07-25 20:07 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Pawlowski CLA 2007-06-18 17:25:56 EDT
Now that the simple cheat sheet editor has a source page, it is easy for the user to corrupt the underlying cheatsheet XML mark-up and have no idea what they did.

Currently, the editor prevents the user from going back to the form page until XML well-formedness errors are corrected in the source page.

The editor should create markers in the source page to flag XML well-formedness errors.
Comment 1 Andrew Johnson CLA 2018-07-25 04:46:28 EDT
This would be quite easy to achieve using an XML schema file. With the right schema, the editor will already indicate errors in the source page:

See documentation for cheatsheets here:
https://help.eclipse.org/photon/index.jsp?topic=%2Forg.eclipse.pde.doc.user%2Fguide%2Ftools%2Feditors%2Fsimple_cs_editor%2Fpage_cheat-sheet.htm
https://help.eclipse.org/photon/topic/org.eclipse.platform.doc.isv/reference/extension-points/cheatSheetContentFileSpec.html
and a machine readable XML schema:
https://help.eclipse.org/photon/topic/org.eclipse.platform.doc.isv/reference/extension-points/cheatSheetContentFileSpec.exsd

The schema file isn't quite valid, so I fixed it and put an example here: 
https://git.eclipse.org/c/mat/org.eclipse.mat.git/tree/plugins/org.eclipse.mat.ui.help/schema/cheatSheetContentFileSpec.xsd

If cheatsheets then reference this schema any errors will be indicated by an XML editor, or on the source page of the simple cheat sheet editor.

The main changes I made were:
<schema
   xmlns:tns="org.eclipse.ui.cheatsheets"
   elementFormDefault="qualified"
to separate the target name space from the schema name space. Is there a neater way of doing this? Otherwise the 'Schema HTML viewer' sees for example the "tns:description" references and the links are broken as the anchor is still "description".

appInfo -> appInfo
case seemed to matter

<element ref="intro"/>
etc. to
<element ref="tns:intro"/>
add a namespace to references to the target name space

use some types to valid IDs e.g.
<attribute name="contextId" type="string">
to
<attribute name="contextId" type="tns:eclipseID">

validate strings according to RegEx patterns e.g. for Java identifiers, Eclipse identifiers, comma separated lists of IDs

<attribute name="href" type="string">
to
<attribute name="href" type="anyURI">
validate URIs

have a type for elements such as description which allows <b> and <br/>

add 
<meta.attribute translatable="true"/>
where required

<attribute name="label"> is now optional on <subitem> as <subitem> can contain description

on attribute definitions, change
use="default" value="false"
to
default="false"
etc. so that the XSD is correct

add param1="" param2="" ... param9="" to <action>

validate the attributes:
<attribute name="translate" type="string">

Note that the original schema specified <action> as a complex type with no subelements - that meant that cheat sheets with 
<action ...>
</action>

would not validate, and would have to be changed to
<action ...  />

Which is right?


The cheatsheet editor then needs some modifications to preserve the extra attributes on the <cheatsheet> element, e.g.
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="org.eclipse.ui.cheatsheets platform:/resource/org.eclipse.mat.ui.help/schema/cheatSheetContentFileSpec.xsd"
   xmlns="org.eclipse.ui.cheatsheets">
and the code which reads the cheatsheet needs to ignore them otherwise these warnings appear in the Eclipse log:

Unknown attribute 'xsi:schemaLocation' specified for element 'cheatsheet'.
Unknown attribute 'xmlns:xsi' specified for element 'cheatsheet'.
Unknown attribute 'xmlns' specified for element 'cheatsheet'.


Once this is done, the help would need to be update to reference the new schema file and a new "Cheat Sheet Content File XML Format" page would need to be built.

What do people think of this idea?