My guess, the schema has a default value of "simple" for the "type" attribute... xerces adds default attributes when validating. Haven't found a way of suppressing this feature.
Phil
-----Original Message-----
From: Dolf Andringa [mailto:dolf.andringa at elcyion.nl]
Sent: Sun 11/20/2005 14:45
To: jdom-interest at jdom.org
Cc:
Subject: [jdom-interest] parsing adds attributes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi All,
Sorry to have another question. This time I did look at the FAQ (both of
JDOM and of Xerces). I've got a question that may be more related tot
Xercers/SAX than JDOM, but I hope you can help me with it.
As soon as I parse an XML document using the apache xalan parser with
the SAX API, elements that do not have attributes automatically get the
attribute type with the value simple. I don't want this. Any idea why
this happens and how I can prevent it from happening?
Code example:
builder=SAXBuilder("org.apache.xerces.parsers.SAXParser")
handelaar=myErrorHandler()
builder.setErrorHandler(handelaar)
builder.setFeature("http://xml.org/sax/features/validation",1)
builder.setFeature("http://apache.org/xml/features/validation/schema",1)
doc=builder.build(sys.argv[1])
nsgml=Namespace.getNamespace("http://www.opengis.net/gml")
nsows=Namespace.getNamespace("http://www.opengis.net/ows1.2")
print doc.getRootElement().getChild("featureMember",nsgml).getAttributes()
This outputs:
[[Attribute: type="simple"]]
The original XML file is in the attachment again.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDgIwbKaTTNeXBMakRAjKgAKCNtxFWxLfluEjESh2xC87A0vUftACdHkmu
GczWm0+blhFTzaEkNZnpQ1o=
=HfAQ
-----END PGP SIGNATURE-----