Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351502 - XML parser factory service registrations by system bundle should include required properties.
Summary: XML parser factory service registrations by system bundle should include requ...
Status: RESOLVED INVALID
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: equinox.framework-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-07 19:50 EDT by John Ross CLA
Modified: 2011-07-08 15:15 EDT (History)
1 user (show)

See Also:


Attachments
proposed patch (2.46 KB, patch)
2011-07-07 20:39 EDT, John Ross CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Ross CLA 2011-07-07 19:50:38 EDT
The OSGi XML Parser Service specification requires parser factory service registrations (SAXParserFactory and DocumentBuilderFactory) to include the following two service properties: parser.validating and parser.namespaceAware. This allows service filters to be used in order to obtain only those factories capable of creating parsers with the required functionality.

Equinox registers a service for each of the two parser factories with default values as part of starting the framework. I realize the parser service specification is part of the compendium but wonder why the same rule wouldn't apply here?
Comment 1 John Ross CLA 2011-07-07 20:39:37 EDT
Created attachment 199303 [details]
proposed patch

This patch modifies the EclipseAdaptorHook to register the two xml parser factories with the required properties and default values.
Comment 2 BJ Hargrave CLA 2011-07-07 21:16:55 EDT
Seems like a good idea.
Comment 3 Thomas Watson CLA 2011-07-08 08:19:04 EDT
Also see bug 88483.  I think most VMs actually do have validating and namespace aware parsers built in, but we don't do the steps at startup to detect if this is true.
Comment 4 Thomas Watson CLA 2011-07-08 08:26:36 EDT
(In reply to comment #0)
> The OSGi XML Parser Service specification requires parser factory service
> registrations (SAXParserFactory and DocumentBuilderFactory) to include the
> following two service properties: parser.validating and parser.namespaceAware.

Note that the specification only requires a value of TRUE if validating or namespaceAware is supported.  All other values or absence indicates FALSE.

Section 702.4 from the compendium spec:

<spec>
• PARSER_NAMESPACEAWARE – The registered parser is aware of name- 
spaces. Name-spaces allow an XML document to consist of indepen- 
dently developed DTDs. In an XML document, they are recognized by the 
xmlns attribute and names prefixed with an abbreviated name-space 
identifier, like: <xsl:if ...>. The type is a Boolean object that must be true 
when the parser supports name-spaces. All other values, or the absence 
of the property, indicate that the parser does not implement name- 
spaces. 

• PARSER_VALIDATING – The registered parser can read the DTD and can 
validate the XML accordingly. The type is a Boolean object that must 
Getting a Parser Factory XML Parser Service Specification Version 1.0 
true when the parser is validating. All other values, or the absence of the 
property, indicate that the parser does not validate. 
</spec>
Comment 5 John Ross CLA 2011-07-08 09:32:53 EDT
(In reply to comment #3)
> Also see bug 88483.  I think most VMs actually do have validating and namespace
> aware parsers built in, but we don't do the steps at startup to detect if this
> is true.

I knew there had to be a similar bug opened somewhere at some point. I just couldn't find it.

(In reply to comment #4)
> Note that the specification only requires a value of TRUE if validating or
> namespaceAware is supported.  All other values or absence indicates FALSE.
> Section 702.4 from the compendium spec:

Okay, fine. I missed that. So if someone wanted to ensure they got a non-validating parser, they could do something like (|!((parser.validating=*))(parser.validating=false)).

Se also bug 351502. We should consider registering a namespace aware parser in addition to or in lieu of the non-namespace aware one if the environment supports it. I don't think bundles should customize factories retrieved from the registry to their own liking since that would affect all other using bundles.
Comment 6 John Ross CLA 2011-07-08 09:35:15 EDT
(In reply to comment #5)
> (In reply to comment #3)
> > Also see bug 88483.  I think most VMs actually do have validating and namespace
> > aware parsers built in, but we don't do the steps at startup to detect if this
> > is true.
> I knew there had to be a similar bug opened somewhere at some point. I just
> couldn't find it.
> (In reply to comment #4)
> > Note that the specification only requires a value of TRUE if validating or
> > namespaceAware is supported.  All other values or absence indicates FALSE.
> > Section 702.4 from the compendium spec:
> Okay, fine. I missed that. So if someone wanted to ensure they got a
> non-validating parser, they could do something like
> (|!((parser.validating=*))(parser.validating=false)).
> Se also bug 351502. We should consider registering a namespace aware parser in
> addition to or in lieu of the non-namespace aware one if the environment
> supports it. I don't think bundles should customize factories retrieved from
> the registry to their own liking since that would affect all other using
> bundles.

I meant to add that I think most would want a namespace aware one, no? Making one available would prevent folks from having to register their own or misuse the existing one.
Comment 7 John Ross CLA 2011-07-08 15:15:57 EDT
Closing as invalid.

First, the properties for xml parser factories do not need to be included if the value is false. Services requiring a value of false can use filters such as the following: (|(!(parser.validating=*))(parser.validating=false)).

Second, the framework, as does the XML Parser Service specification, uses a ServiceFactory to deliver xml parser factories to requesting bundles. This means a bundle is free to modify the factory settings (e.g., setNamespaceAware and setValidating) as it pleases without affecting other bundles.

If a bundle registers a parser factory without using a service factory, it's not following the spec and all bets are off.