Bugs and extensions

Hi,

here are a couple of errors I found in the code:

1) Bug in characters method. Because of this bug
   Aelfred parser did not work (I think that the same
   reason is true for IBM parser xml4j version 2_X):

	String sTrimmed = s.trim();
	if (sTrimmed.length() > 0 && !bHasData) {
	    e.addChild (new Data (s));
	} else {
	    dataNode.set (dataNode.data() + s);
	}

	(what if dataNode==null?)
	SHOULD BE:

	String sTrimmed = s.trim();
	if (sTrimmed.length() > 0) {
	  if(!bHasData)
	    e.addChild (new Data (s));
	  else
	    dataNode.set (dataNode.data() + s);
	}

2) equals methods in Resource and Property are incorrect
   (they expect Resource resp. Property objects as input!)
   Should be something like this:

    public boolean equals (Object that) {

      if (this == that)
	  return true;
      if (that == null || !(that instanceof Resource))
	  return false;

      return m_sURI.equals( ((Resource)that).m_sURI );

3) The parser reads first the content into a String.
   This is slow:
	    StringReader sr = new StringReader (m_RDFsource.content());
	    InputSource source = new InputSource (sr);

   In fact, RDFSource class is not needed. Why not using
   InputSource of SAX directly?

4) isTypedPredicate: ordinal type forgotten:
		e.name().endsWith ("type") ||
		e.name().endsWith ("value") ||
MISSING		e.name().indexOf("_") >= 0 ||
		e.name().endsWith ("Property") ||
		e.name().endsWith ("Statement")) {

5)  Bug in SAX driver handling (only default driver was accepted).
    Comment out:

   //	m_sXMLParser = "com.ibm.xml.parser.SAXDriver";

6) check for ListItems nested within a description has to be removed
since SiRPAC does not check schema info (this Description may have a
property rdf:type -> rdf:Bag)

7) Class Property is not needed at all since
   what is property can be determined only
   evaluating schemas! Use Resource instead.

8) Bug (or feature) in Java URL implementation
   causes incorrect behaviour: 

	new URL("file", null, "temp") = "file:temp"
        new URL("file:temp") = "file:/temp"
                     ===            ===

	=> correct Element.java because of a bug in URL.java

		    URL absoluteURL = new URL (sURI);
		    sResult = absoluteURL.toString();

		goes

		    URL absoluteURL = new URL (sURI);
		    sResult = sURI;

9) Bug: example in the schema specs.

   <MaritalStatus rdf:ID="Married"/>

   is handled incorrectly (check it please)
   Problem: implicit namespace


Extension suggestion: some callback facility is needed to provide
external schema handling.  E.g.:

	if (m_bFetchSchemas) {
	    while (SiRPAC.s_vNStodo.size() > 0) {
		String sURI = (String)SiRPAC.s_vNStodo.elementAt(0);
		SiRPAC.s_vNStodo.removeElementAt(0);
		SiRPAC.s_vNSdone.addElement (sURI);

		fetchSchema(sURI);
		=================
	    }
	}

	whereas fetchSchema can be overridden by subclassing SiRPAC

Final comment: I'm working on a RDF parser/serializer with schema
support and validation. It relies on SiRPAC for parsing. I'll probably
release it for public use in a couple of weeks.

Ciao,
Sergey

Received on Tuesday, 18 May 1999 14:47:56 UTC