Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 18910 - MIME-resolver DTD is confusing and hard to read
MIME-resolver DTD is confusing and hard to read
Status: RESOLVED WONTFIX
Product: platform
Classification: Unclassified
Component: Filesystems
3.x
All All
: P3 (vote)
: TBD
Assigned To: Jaroslav Tulach
issues@platform
: API
Depends on:
Blocks: 31977 199927
  Show dependency treegraph
 
Reported: 2001-12-21 18:18 UTC by Jesse Glick
Modified: 2011-07-06 20:39 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2001-12-21 18:18:01 UTC
Please consider producing a revised MIME resolver DTD that would be easier to
understand. Even after having used it, I cannot remember how it is supposed to
work without referring to the docs, and even then it is hard to follow. There
would be no compatibility problem with making a new DTD since we would just
provide a different processor.

Problems with the current version (syntactic, not feature complaints):

1. <exit/> or <resolver mime="null"/>: first, there ought not be equivalent ways
of saying the same thing, this just increases confusion. Second, does this exit
out of the entire <MIME-resolver>? If so, it is not clearly documented to do so.

2. <MIME-resolver> is mixed-case whereas all other elements and attrs are
lower-case.

3. <file> is an odd name for one rule.

4. Why are most rules children of <file> but <xml-rule> is a child of
<resolver>? This seems very counterintuitive. If you have resolved it, why are
there then more rules inside? Why not just make <pi>, <doctype>, and <element>
children of <file> like other things?

5. It is not obvious when reading things what is conjunctive and what
disjunctive. I.e. it seems that at least one rule beneath <file> must match -
disjunction. It does not appear to be document in the case of <xml-rule>. It
would be hard to guess what was meant without carefully reading DTD
documentation. This is perhaps the major thing.

6. Messy that ns can be an attr or child of <element> - pick one (child) and
stick to it.

Suggest a more uniform syntax based more on boolean logic, such as:

<mime-resolver>
  <resolver mime="text/x-ant+xml">
    <and>
      <ext name="xml"/>
      <xml-element name="project">
        <attr name="default"/>
      <xml-element>
    </and>
  </resolver>
</mime-resolver>

It would be much easier to understand what was meant IMHO. Minor changes would
work intuitively, e.g. match a different extension too but check in XML:

<mime-resolver>
  <resolver mime="text/x-ant+xml">
    <and>
      <or>
        <ext name="xml"/>
        <ext name="ant"/>
      </or>
      <xml-element name="project">
        <attr name="default"/>
      <xml-element>
    </and>
  </resolver>
</mime-resolver>

vs. match a different extension and trust it:

<mime-resolver>
  <resolver mime="text/x-ant+xml">
    <or>
      <and>
        <ext name="xml"/>
        <xml-element name="project">
          <attr name="default"/>
        <xml-element>
      </and>
      <ext name="ant"/>
    </or>
  </resolver>
</mime-resolver>

cancel with file attrs:

<mime-resolver>
  <exit>
    <fattr name="not-ant" text="true"/>
  </exit>
  <resolver mime="text/x-ant+xml">
    <and>
      <ext name="xml"/>
      <xml-element name="project">
        <attr name="default"/>
      <xml-element>
    </and>
  </resolver>
</mime-resolver>

Something more like Lisp might even be better:

<mime-resolver>
  <if>
    <test><fattr name="not-ant" text="true"/></test>
    <then><fail/></then>
    <else>
      <if>
        <test>
          <and>
            <ext name="xml"/>
            <xml-element name="project">
              <attr name="default"/>
            <xml-element>
          </and>
        </test>
        <then><succeed mime="text/x-ant+xml"/></then>
        <else><fail/></else>
      </if>
    </else>
  </if>
</mime-resolver>

where

% rule = fattr | ext | xml-element | ...
% boolterm = %rule; | and | or | not
% mimeterm = succeed | fail | if
mime-resolver: (%mimeterm;)
if: (test, then, else)
test: (%boolterm;)
then: (%mimeterm;)
else: (%mimeterm;)
and: (%boolterm;)+
or: (%boolterm;)+
not: (%boolterm;)
succeed: EMPTY; ATTLIST: mime
fail: EMPTY
Comment 1 _ pkuzel 2002-01-07 10:47:03 UTC
A good proposal, I appreciate mainly explicit <and> and <or> that are
not obvious from current doc.

1) <exit/> exits a <file>.
3) <file> rules represents out of band information accessible without
reading a file content (except <magic>).
4) <resolver> rules represents a second stage - a file content test
for files that passed the first stage.
5) original idea was: element content is disjunctive element
attributes are conjunctive.
6) ns attribute is a shortcut for one namespace child. Every element
that allows children can contain an attribute if only one choice is
required instead of a single child element.
Comment 2 Jesse Glick 2002-01-07 14:53:31 UTC
4. - makes sense for performance but with an explicit boolean logic
flow, writers of resolvers can do this manually (list out-of-band
tests first in the hope that they will short-circuit the in-band
tests); and since the resolver is purely declarative, the impl is free
to rearrange clauses too (and merge clauses from different resolvers...).

6. - OK but I think it is better to have a simpler DTD that can be
understood a little more quickly than to save a little bit of typing,
if the semantics are the same.
Comment 3 Marek Grummich 2002-07-22 11:19:56 UTC
Set target milestone to TBD
Comment 4 Marek Grummich 2002-07-22 11:22:23 UTC
Set target milestone to TBD
Comment 5 Jesse Glick 2003-03-13 15:37:26 UTC
See issue #31977 for justification of increased priority.
Comment 6 Antonin Nebuzelsky 2008-04-15 17:08:38 UTC
Reassigning to new module owner jskrivanek.
Comment 7 Jaroslav Tulach 2010-04-02 18:13:50 UTC
I know we have two DTDs. One is simpler, second is complex. The wizard generates the simpler one. If you want something even simpler, feel free to design 3rd DTD and read it.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo