Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6406704

Synth and JavaBeans DTDs are not valid

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs

      Description

      A DESCRIPTION OF THE REQUEST :
      The DTDs that describe the JavaBeans and Synth file formats are not valid.

      It has been a longstanding problem that the Synth file format has not been well described by the DTD included, which makes it difficult to figure out what constructs are legal and could be expected to work and which ones are intentionally not supported. The current synth.dtd (version 1.11 05/11/17) contains a parameter entity "beansPersistance" [sic!] which is never defined. One can gather from the behaviour of programs that this is intended to be a reference to subelements of the java element defined in javabeans.dtd (of which I have only found a non-versioned copy at http://java.sun.com/products/jfc/tsc/articles/persistence3/javabeans.dtd).



      JUSTIFICATION :
      It is noted in the available documentation that "While the DTD for synth is specified, the parser is not validating" and one is encouraged to ignore the DTD. This is unsatisfactory for two reasons:
      1. Using Synth descriptions to define corporate styles is much more easily modularised if the XML files can be split into multiple files that are then included into a master XML file. One does not want to do this inclusion manually by editing the master file, but by using the inclusion mechanism of XML. This requires the use of a DOCTYPE declaration, which in turn requires an existing and valid DTD file.
      2. The DTD is the most unambiguous description of what is allowed in a Synth XML file and therefore is a an important part of the documentation. It should therefore correspond to the reality.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I want the synth.dtd and javabeans.dtd files to be valid DTDs.

      In addition they should be modified so that the relation between the <java> and the <synth> element is made clear. Since Persistent Beans should be possible to use without Synth it probably is not a good idea to simply replace the <java> tag with the <synth> tag. A better alternative would be to separate out the declarations common to both DTDs into a third file, from which both can include them, so that one can use either the <java> or the <synth> toplevel tag but not both.
      ACTUAL -
        Today a reference to synth.dtd in a DOCTYPE declaration causes parsing to fail.

      Further, the co-existence between Persistent Beans and Synth is unclear: the former has a top-level tag <java>, the latter has the top-level tag <synth>. Currently these can apparently be used in any arbitrary order, which I'm not quite sure is the best way to do it.

      ---------- BEGIN SOURCE ----------
      DemoDemo.java:

      import java.awt.*;
      import java.text.*;
      import java.util.*;
      import javax.swing.*;
      import javax.swing.plaf.synth.*;

      public class Demo {
        
        public Demo() {
            SynthLookAndFeel laf = new SynthLookAndFeel();
            try {
              laf.load(Demo.class.getResourceAsStream("try.xml"), Demo.class);
            } catch (ParseException e) {
              System.err.println("Parsing of try.xml failed with " + e.getMessage());
            }
            try {
              UIManager.setLookAndFeel(laf);
            } catch (UnsupportedLookAndFeelException e) {
              System.err.println("Look and Feel setting failed with " + e.getMessage());
            }
        }

        public static void main(String args[]) {
          Demo d = new Demo();
        }

      }


      try.xml:

      <?xml version="1.0" encoding="iso-8859-1"?>
      <!DOCTYPE java SYSTEM "synth.dtd">
      <java>
      <synth>
      </synth>
      </java>

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      One way to work around the inclusion problemis to manually edit the XML files, but this is impractical for larger projects where there may be dozens of different files that need to be included in particular combinations.

      As suggested above, one can split the files into three, in the following manner:
      (There are still likely to be problems with the actual declarations in that they may not match the actual behaviour of the software, but that is another problem.)

      persistence.dtd:

      <!ENTITY % beansPersistance
         "object |
          void |
          string |
          class |
          null |
          array |
          boolean |
          byte |
          char |
          short |
          int |
          long |
          float |
          double">


      <!ELEMENT boolean (#PCDATA)>
      <!ELEMENT byte (#PCDATA)>
      <!ELEMENT char (#PCDATA)>
      <!ELEMENT short (#PCDATA)>
      <!ELEMENT int (#PCDATA)>
      <!ELEMENT long (#PCDATA)>
      <!ELEMENT float (#PCDATA)>
      <!ELEMENT double (#PCDATA)>

      <!ELEMENT string (#PCDATA)>
      <!ELEMENT class (#PCDATA)>
      <!ELEMENT null (#PCDATA)>

      <!ELEMENT object (
          object |
          void |
          string |
          class |
          null |
          array |
          boolean |
          byte |
          char |
          short |
          int |
          long |
          float |
          double
      )*>
      <!ATTLIST object
          id ID #IMPLIED
          idref IDREF #IMPLIED
          class CDATA #IMPLIED
          field CDATA #IMPLIED
          method CDATA #IMPLIED
          property CDATA #IMPLIED
          index CDATA #IMPLIED
      >

      <!ELEMENT array (
          object |
          void |
          string |
          class |
          null |
          array |
          boolean |
          byte |
          char |
          short |
          int |
          long |
          float |
          double
      )*>
      <!ATTLIST array
          id ID #IMPLIED
          class CDATA #IMPLIED
          length CDATA #IMPLIED
      >

      <!ELEMENT void (
          object |
          void |
          string |
          class |
          null |
          array |
          boolean |
          byte |
          char |
          short |
          int |
          long |
          float |
          double
      )*>
      <!ATTLIST void
          id ID #IMPLIED
          class CDATA #IMPLIED
          method CDATA #IMPLIED
          property CDATA #IMPLIED
          index CDATA #IMPLIED
      >


      javabeans.dtd:

      <!ENTITY % persistence SYSTEM "persistence.dtd">

      %persistence;

      <!ELEMENT java ( %beansPersistance; )*>
      <!ATTLIST java
          version CDATA #IMPLIED
          class CDATA #IMPLIED
      >

      synth.dtd:

      <!--
       @(#)synth.dtd X.XX 2006-03-30
       
       Copyright 2006 Sun Microsystems, Inc. All rights reserved.
       SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
       Modified for demo purposes by ###@###.###.
      -->


      <!ENTITY % persistence SYSTEM "persistence.dtd">

      %persistence;

      <!ELEMENT synth ((%beansPersistance;) | style | bind | font | color |
                imagePainter | imageIcon | inputMap | defaultsProperty)*>
      <!ATTLIST synth
                version CDATA #IMPLIED
      >

      <!ELEMENT style (property | defaultsProperty | state | font |
                graphicsUtils | insets | painter | imagePainter | opaque |
                inputMap | %beansPersistance; | imageIcon)*>
      <!ATTLIST style
                id ID #IMPLIED
                clone IDREF #IMPLIED
      >

      <!ELEMENT state (font | color | painter | imagePainter |
                (%beansPersistance;) | property | imageIcon)*>
      <!ATTLIST state
                id ID #IMPLIED
                clone IDREF #IMPLIED
                value CDATA #IMPLIED
                idref IDREF #IMPLIED
      >

      <!ELEMENT font EMPTY>
      <!ATTLIST font
                id ID #IMPLIED
                idref IDREF #IMPLIED
                name CDATA #IMPLIED
                style CDATA #IMPLIED
                size CDATA #IMPLIED
      >

      <!ELEMENT color EMPTY>
      <!ATTLIST color
                id ID #IMPLIED
                idref IDREF #IMPLIED
                type CDATA #IMPLIED
                value CDATA #IMPLIED
      >

      <!ELEMENT property EMPTY>
      <!ATTLIST property
                key CDATA #REQUIRED
                type (idref|boolean|dimension|insets|integer|string) "idref"
                value CDATA #REQUIRED
      >

      <!ELEMENT defaultsProperty EMPTY>
      <!ATTLIST defaultsProperty
                key CDATA #REQUIRED
                type (idref|boolean|dimension|insets|integer|string) "idref"
                value CDATA #REQUIRED
      >

      <!ELEMENT graphicsUtils EMPTY>
      <!ATTLIST graphicsUtils
                idref IDREF #REQUIRED
      >

      <!ELEMENT insets EMPTY>
      <!ATTLIST insets
                id ID #IMPLIED
                idref IDREF #IMPLIED
                top CDATA #IMPLIED
                bottom CDATA #IMPLIED
                left CDATA #IMPLIED
                right CDATA #IMPLIED
      >

      <!ELEMENT bind EMPTY>
      <!ATTLIST bind
                style IDREF #REQUIRED
                type (NAME|REGION) "REGION"
                key CDATA #REQUIRED
      >

      <!ELEMENT painter EMPTY>
      <!ATTLIST painter
                idref IDREF #IMPLIED
                method CDATA #IMPLIED
                direction (north|south|east|west|top|left|bottom|right|horizontal|vertical|horizontal_split|vertical_split) #IMPLIED
      >

      <!ELEMENT imagePainter EMPTY>
      <!ATTLIST imagePainter
                id ID #IMPLIED
                method CDATA #IMPLIED
                direction (north|south|east|west|top|left|bottom|right|horizontal|vertical|horizontal_split|vertical_split) #IMPLIED
                path CDATA #IMPLIED
                sourceInsets CDATA #IMPLIED
                destinationInsets CDATA #IMPLIED
                paintCenter (true|false) "true"
                stretch (true|false) "true"
                center (true|false) "false"
      >

      <!ELEMENT imageIcon EMPTY>
      <!ATTLIST imageIcon
                id ID #REQUIRED
                path CDATA #REQUIRED
      >

      <!ELEMENT opaque EMPTY>
      <!ATTLIST opaque
                value (true|false) "true"
      >

      <!ELEMENT inputMap (bindKey)*>
      <!ATTLIST inputMap
                id ID #REQUIRED
      >

      <!ELEMENT bindKey EMPTY>
      <!ATTLIST bindKey
                key CDATA #REQUIRED
                action CDATA #REQUIRED
      >

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: