You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@netbeans.apache.org by GitBox <gi...@apache.org> on 2017/11/04 23:34:51 UTC

[GitHub] matthiasblaesing commented on issue #241: [NETBEANS-112] Re-integrate DTD for RSS 0.91 feed

matthiasblaesing commented on issue #241: [NETBEANS-112] Re-integrate DTD for RSS 0.91 feed
URL: https://github.com/apache/incubator-netbeans/pull/241#issuecomment-341937684
 
 
   I'm a bit reluctant to merge this. Quite frankly, it neither no license, nor the create commons license sound like a good idea for a document, that is used as a basis for parsers. For our use case I'd try to stay away from this as far as possible. I propose a different approach:
   
   The only really interesting think that is part of the DTD are the entity definitions, that are needed to correctly parse the XML stream. The rest is plain XML and the document structure is already manually handled and the stream is also not validated.
   
   From the RSS DTD:
   
   > Copied from HTML 3.2 DTD, with modifications (removed CDATA)
   
   Now the entities covered by HTML 3.2 are identical with Character entity set of XHTML 1.0 (this is important, as the HTML 3.2 entity definitions are SGML and the XML parser can't read them).
   
   That entity definition was already merged into the apache netbeans codebase with #240.
   
   So this assumes, that `xhtml-lat1.ent` is copied from `html.editor` to `welcome` module and placed in the `org.netbeans.modules.welcome.resources` package.
   
   There are two places where XMLReader are instantiated (one in `RSSFeed.java` and one in `CombinationRSSFeed.java`). My hack does this:
   
   ```java
           reader.setEntityResolver( org.openide.xml.EntityCatalog.getDefault() );
   ```
   
   is replaced by:
   
   ```java
           reader.setEntityResolver( new EntityResolver() {
               @Override
               public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
                   if("http://my.netscape.com/publish/formats/rss-0.91.dtd".equals(systemId)
                           || "-//Netscape Communications//DTD RSS 0.91//EN".equals(publicId)) {
                       return new InputSource(RSSFeed.class.getResourceAsStream("/org/netbeans/modules/welcome/resources/xhtml-lat1.ent"));
                   } else {
                       return org.openide.xml.EntityCatalog.getDefault().resolveEntity(publicId, systemId);
                   }
               }
           } );
   ```
   
   So I pretend to handle the XML parser the correct DTD, but that DTD only contains entity definitions and misses the structure information. The structural aspects are handled in `FeedHandler` inside `RSSFeed` which does not depend on the information from the DTD.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services