You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Michel Goossens <Mi...@cern.ch> on 2000/01/12 14:36:24 UTC

Xerces and Schema problem?

When I use this little file info.xml

<!DOCTYPE info SYSTEM "info.dtd">
<info>
  <p>XML'99 was a <em>big </em> success</p>
</info>

and this DTD info.dtd

<!ELEMENT info (p)*             >
<!ELEMENT p    (#PCDATA|em)*    >
<!ELEMENT em   (#PCDATA)        >
<!ATTLIST em   font (b|i|u) "i" >

with xerces version 1.0.1 and the command (both with JDK 1.1.6 and 1.2)

java org.apache.xerces.domx.XGrammarWriter info.xml

I get the following error 

error: Error parsing document (info.xml).
java.lang.NullPointerException
        at java.io.PrintStream.write(Compiled Code)
        at java.io.PrintStream.write(Compiled Code)
        at java.io.PrintStream.print(Compiled Code)
        at java.io.PrintStream.println(Compiled Code)
        at java.lang.Throwable.printStackTrace(Compiled Code)
        at org.apache.xerces.domx.XGrammarWriter.main(Compiled Code)

Whereas with xerces version 1.0.0 I get a (old) schema file, as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Grammar referenced in document: "info.xml" -->
<!DOCTYPE schema PUBLIC "-//W3C//DTD XML Schema Version 1.0//EN"
"http://www.w3.org/XML/Group/1999/09/23-xmlschema/structures/structures.dtd">
<schema>
  <element name="info">
    <archetype>
      <element maxOccurs="*" minOccurs="0" ref="p"/>
    </archetype>
  </element>
  <element name="p">
    <archetype content="mixed">
      <element ref="em"/>
    </archetype>
  </element>
  <element name="em">
    <archetype content="mixed">
      <attribute default="i" name="font" type="NMTOKEN">
        <enumeration>
          <literal>b</literal>
          <literal>i</literal>
          <literal>u</literal>
        </enumeration>
      </attribute>
    </archetype>
  </element>
</schema>

Does somebody have an explanation for this behavior. The sources of
org/apache/xerces/domx/XGrammarWriter.java are identical in versions
1.0.0 and 1.0.1 and all other samples in the distribution that I
tested seem to work. 

Thanks, mg