Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 248453 - [ds tooling] Validate <property> element
Summary: [ds tooling] Validate <property> element
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Chris Aniszczyk CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-24 11:12 EDT by Simon Archer CLA
Modified: 2008-09-30 22:11 EDT (History)
1 user (show)

See Also:


Attachments
ErrorReporter updates (4.55 KB, text/plain)
2008-09-30 19:03 EDT, Rafael Oliveira Nóbrega CLA
caniszczyk: iplog+
Details
DSProperty update (875 bytes, text/plain)
2008-09-30 19:11 EDT, Rafael Oliveira Nóbrega CLA
caniszczyk: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Archer CLA 2008-09-24 11:12:46 EDT
Using Eclipse 3.5M2

A component's <property> element has an optional "value" attribute.  The two legal forms are used to:

- Define a SINGLE property value, using the "value" attribute.

   <property name="ports" type="Integer" value="80">


- Define an ARRY of property values, using <property> content instead of the "value" attribute:

   <property name="ports" type="Integer">
      80,
      8080
   </property>

So, the following should be flagged as a WARNING, since it uses both the "value" attribute AND has contents.

   <property name="ports" type="Integer" value="80">
      80,
      8080
   </property>


Section 112.4.5 of the OSGi spec has this to say about using <property> element's content to define an ARRAY of values. Emphasis is mine.

- "If the value attribute is not specified, the body of the property element MUST contain one or more values."

- "Values MUST be placed one per line and blank lines are ignored."

- "Parsing of the value is done by the parse methods in the class identified by the type, after trimming the line of any beginning and ending white space."


These 3 pieces of information from the spec should help define the necessary validation for the <property> element.

While some might see this level of validation as unnecessary, the selling point for PDE is that it catches runtime errors for you during development.  I realize that I'm probably preaching to the choir here, but I felt it was good to mention.
Comment 1 Chris Aniszczyk CLA 2008-09-30 16:46:38 EDT
Feel like making enhancements to the error report Rafael?
Comment 2 Rafael Oliveira Nóbrega CLA 2008-09-30 19:03:20 EDT
Created attachment 113935 [details]
ErrorReporter updates

Now we check:
-If value attr is blank or null, we must define a body value
-If value attr is not blank or null, we cannont define a body value

Chris, could you please check the messages...

Doubt: Is that ok to create a new 'property' with warning? Because we don't use any default value for new 'property' elements, right? Should we? :)
Comment 3 Chris Aniszczyk CLA 2008-09-30 19:04:26 EDT
we should give a default value

maybe a string type with value 'value'

Can you address that too?
Comment 4 Rafael Oliveira Nóbrega CLA 2008-09-30 19:07:21 EDT
sure!
Comment 5 Rafael Oliveira Nóbrega CLA 2008-09-30 19:11:57 EDT
Created attachment 113936 [details]
DSProperty update

Now we create a default value for property elements.

(the previous patch is still a valid one, ok?)
Comment 6 Chris Aniszczyk CLA 2008-09-30 19:39:42 EDT
Thanks! :D
Comment 7 Chris Aniszczyk CLA 2008-09-30 19:39:55 EDT
done.

> 20090930
Comment 8 Simon Archer CLA 2008-09-30 20:36:15 EDT
Chris, I would like to see the following marked as illegal, since having both a value attribute (even one with any empty string) and element content is wrong:

   <property name="property1" type="Integer" value="">
      10
   </property>

The value="" should probably be identified as the error.
Comment 9 Chris Aniszczyk CLA 2008-09-30 21:44:11 EDT
Fixed Simon's case.

Also fixed some wording issues.

Also fixed a potential invalid thread access issue.

Thanks Simon.
Comment 10 Simon Archer CLA 2008-09-30 21:54:03 EDT
This should be legal, but is currently marked with a warning:

   <property name="foo" type="String" value=""/>

The warning is:

  If the ''value'' attribute is not specified, the body of the
  property element must contain one or more values.

This, of course, is a special case since a property of type "String" can have
"" as the value, which equates to an empty string.  A corner case for sure.
I've tested this with Equinox's implementation of DS and it is legal.
  
Comment 11 Chris Aniszczyk CLA 2008-09-30 22:11:01 EDT
done.

> 20090930