GithubHelp home page GithubHelp logo

jaxb-dtd-parser's Introduction

jaxb-dtd-parser's People

Contributors

antoniosanct avatar eclipse-jaxb-impl-bot avatar jbescos avatar lukasj avatar tomas-kraus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jaxb-dtd-parser's Issues

Unclear License Type

License file says this component is under BSD-3-Clause license, while notice file says it's under EPL-1.0 license. Which one is it then?

Occurrence constants are misspelled

The constants for occurrence constraints are all missing a second r. As these constants are already part of public API and cannot be changed without breaking backwards compatibility, it's probably best to deprecate the misspelled ones and add new ones with proper spelling and the same values:

+   public final short OCCURRENCE_ZERO_OR_MORE = 0;
+
+   @Deprecated
    public final short OCCURENCE_ZERO_OR_MORE = 0;
+
+   public final short OCCURRENCE_ONE_OR_MORE = 1;
+
+   @Deprecated
    public final short OCCURENCE_ONE_OR_MORE = 1;
+
+   public final short OCCURRENCE_ZERO_OR_ONE = 2;
+
+   @Deprecated
    public final short OCCURENCE_ZERO_OR_ONE = 2;
+
+   public final short OCCURRENCE_ONCE = 3;
+
+   @Deprecated
    public final short OCCURENCE_ONCE = 3;

"Illegal parameter entity reference syntax" on W3C DTD for SMIL 3.0

Using dtd-parser trunk code I cannot parse W3C SMIL DTDs. I'm using XJC
2.2.3 to generate JAXB classes for SMIL 3.0:

----- console output -----
$xjc -dtd -d
/data/Dev/Java/XML/SMIL/w3c/org.w3c.smil30.dtd/src/output/java -p
org.w3c.smil30 /data/Dev/Java/XML/SMIL/w3c/DTD/SMIL30Language.dtd
parsing a schema...
[ERROR] Illegal parameter entity reference syntax
line 81 of file:/data/Dev/Java/XML/SMIL/w3c/DTD/SMIL-layout.mod

Failed to parse a schema.


In the extract below line 81 is %SMIL.common-layout-attrs;
----- dtd extract -----


I really don't see what's wrong, and I doubt W3C would produce invalid
DTD.
So I guess it's some sort of bug in dtd-parser.

DTDs can be downloaded at this url:
http://www.w3.org/TR/SMIL/DTD.zip

More info on SMIL DTDs:
http://www.w3.org/TR/SMIL/smil-DTD.html

Any help would be great.

Merry Xmas!

Environment

Arch Linux 64 bit, JDK 6

Affected Versions

[current]

Public Release

Last CTS runs indicate no failures in this component. It's time to make a public release. Before the release make sure that Eclipse Release Review is passed and all dependencies have been released.

Parser parses #IMPLIED use attributes as NORMAL (and vice versa)

I believe that there is a fundamental flaw in the DTDParser's attribute use parsing. Using various test DTDs, it appears that attributes with #IMPLIED default declarations are assigned attribute use USE_NORMAL. Vice versa, attributes with a declared default value (and neither #IMPLIED, #REQUIRED nor #FIXED designation) do appear as USE_IMPLIED.

The following test case, I believe, demonstrates this issue with a very simple DTD:

import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
import com.sun.xml.dtdparser.DTDParser;
import com.sun.xml.dtdparser.DTDHandlerBase;
import com.sun.xml.dtdparser.DTDEventListener;
import org.junit.Test;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import static org.junit.Assert.assertEquals;

public class AttributeUseTest
{
  Map<String, Short> attributes = new HashMap<>();

  public AttributeUseTest() throws Exception
  {
    String dtd =
    """
      <!ELEMENT root EMPTY>
      <!ATTLIST root
        normal CDATA "default"
        implied CDATA #IMPLIED
        required CDATA #REQUIRED
        fixed CDATA #FIXED "default"
      >
    """;
    DTDEventListener handler = new DTDHandlerBase()
    {
      @Override
      public void attributeDecl(String element, String name, String type, String[] enums, short use, String defaultValue) throws SAXException
      {
          attributes.put(name, use);
      }
    };
    InputSource input = new InputSource(new StringReader(dtd));
    DTDParser parser = new DTDParser();
    parser.setDtdHandler(handler);
    parser.parse(input);
  }

  @Test
  public void testNormalAttribute()
  {
    assertEquals(DTDEventListener.USE_NORMAL, attributes.get("normal").shortValue());
  }

  @Test
  public void testImpliedAttribute()
  {
    assertEquals(DTDEventListener.USE_IMPLIED, attributes.get("implied").shortValue());
  }

  @Test
  public void testRequiredAttribute()
  {
      assertEquals(DTDEventListener.USE_REQUIRED, attributes.get("required").shortValue());
  }

  @Test
  public void testFixedAttribute()
  {
      assertEquals(DTDEventListener.USE_FIXED, attributes.get("fixed").shortValue());
  }
}

The test cases for #REQUIRED and #FIXED pass as expected, but the two other test cases both fail.

As I ran this in the debugger, I noticed some strange looking code in DTDParser.maybeAttlistDecl():

} else if (!peek("#IMPLIED")) {
attributeUse = DTDEventListener.USE_IMPLIED;

Intuitively, the negation !peek("#IMPLIED") (instead of just peek("#IMPLIED")) seems incorrect here, since it would select USE_IMPLIED specifically if #IMPLIED was not present. This explains why attributes without any default declarations end up being recognized as implied.

Further down, USE_NORMAL is assigned as a fallback value:

} else {
// TODO: this looks like an fatal error.
attributeUse = DTDEventListener.USE_NORMAL;

This explains why #IMPLIED attributes (which do not get recognized further up, due to the negation) are designated as USE_NORMAL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.