470,815 Members | 1,246 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

General entity references and Schema validation problem (using Xerces2)

Hello everyone,
I'm having trouble using Xerces2(2.4, 2.5) when validating against an
XML schema if a general entity reference is defined within the XML
The error I'm getting is this: "org.xml.sax.SAXParseException: Element
type "personnel" must be declared."

Xerces1(1.4.3, 1.4.4) doesn't have an issue with this. As is XML Spy.
Is there any other Xerces feature/property that I need to enable/set?
It works if I remove the entity reference "test".

Below is the cut-down version XML file and the schema:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE personnel [
<!ENTITY test "test123">

<personnel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<person id="Big.Boss">

================================================== ========
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="personnel">
<xs:element ref="person" maxOccurs="unbounded"/>

<xs:element name="person">
<xs:element ref="name"/>
<xs:attribute name="id" type="xs:ID" use="required"/>

<xs:element name="name">
<xs:element ref="family"/>
<xs:element ref="given"/>

<xs:element name="family" type="xs:string"/>
<xs:element name="given" type="xs:string"/>

================================================== ======
(java code)
package jdomexample;

import java.io.*;
import java.util.*;
import org.jdom.*;
import org.jdom.input.*;
import org.apache.xerces.parsers.SAXParser;

public class configParser {

private static final String DEFAULT_SAX_DRIVER_CLASS =
private String saxDriverClass;
private SAXBuilder builder;

// CONSTRUCTOR - create instance of SAXBuilder for use in the rest
of the program
public configParser(String saxDriverClass) {
builder = new SAXBuilder(saxDriverClass, true);

public void read(String filename) throws IOException, JDOMException
Document doc = builder.build(new File(filename));
Element root = doc.getRootElement();

// This provides a static entry point for reading an XML file using
public static void main(String args[]) {
PrintStream out = System.out;
if (args.length != 1) {
out.println("Usage: jdomexample.configParser [xml config

// Load filename and SAX driver class
String filename = args[0];
String saxDriverClass = DEFAULT_SAX_DRIVER_CLASS;

// Create an instance of the tester and test
try {
configParser cp = new configParser(saxDriverClass);
} catch (JDOMException e) {
if (e.getCause() != null) {
} else {
} catch (Exception e) {
Jul 20 '05 #1
1 2727
I'm having the same problem. Can you share the solution with me? Thanks!
Sep 1 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Robert Lintner | last post: by
1 post views Thread by Ole Hedegaard | last post: by
6 posts views Thread by Phil Jarvis | last post: by
1 post views Thread by i.am.thor | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.