T
Tassilo Horn
Hi all,
I'm using a SAXParser created with a SAXParserFactory with a custom
ContentHandler for parsing XML files and creating some graph
representation of the files contents.
Currently, I generate plain trees, but what I really want is to indicate
cross references as well, as given by element attributes of type
ID/IDREF.
However, Attributes.getType(int) reports only CDATA for all attributes.
So probably I need to create a validating parser. I tried that, but
still no luck, and SAXParserFactory.setValidating(boolean) says that
this is mostly for DTDs anyway and I should set a Schema using
setSchema().
However, the XML files I parse may be completely arbitrary, so I cannot
set some fixed schema. But at least I can presume that they all declare
their schemas properly (and in general there are mostly well-known
schemas), like
--8<---------------cut here---------------start------------->8---
<?xml version="1.0" encoding="UTF-8"?>
<uml
ackage xmi:version="2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.1"
xsi:schemaLocation="http://schema.omg.org/spec/UML/2.1.1 http://www.eclipse.org/uml2/2.1.0/UML"
xmi:id="_FbjLzPlaEeCo98mycbxXgw" name="de.uko.nsd.NSDSchema">
--8<---------------cut here---------------end--------------->8---
Isn't there something that retrieves the needed schemas automatically by
the declarations given in the XML file?
(I remember some years back, I've used some open-source parser [maybe
xerces] that did exactly that when some option was set.)
Thanks for any pointers!
Bye,
Tassilo
I'm using a SAXParser created with a SAXParserFactory with a custom
ContentHandler for parsing XML files and creating some graph
representation of the files contents.
Currently, I generate plain trees, but what I really want is to indicate
cross references as well, as given by element attributes of type
ID/IDREF.
However, Attributes.getType(int) reports only CDATA for all attributes.
So probably I need to create a validating parser. I tried that, but
still no luck, and SAXParserFactory.setValidating(boolean) says that
this is mostly for DTDs anyway and I should set a Schema using
setSchema().
However, the XML files I parse may be completely arbitrary, so I cannot
set some fixed schema. But at least I can presume that they all declare
their schemas properly (and in general there are mostly well-known
schemas), like
--8<---------------cut here---------------start------------->8---
<?xml version="1.0" encoding="UTF-8"?>
<uml
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://schema.omg.org/spec/UML/2.1.1"
xsi:schemaLocation="http://schema.omg.org/spec/UML/2.1.1 http://www.eclipse.org/uml2/2.1.0/UML"
xmi:id="_FbjLzPlaEeCo98mycbxXgw" name="de.uko.nsd.NSDSchema">
--8<---------------cut here---------------end--------------->8---
Isn't there something that retrieves the needed schemas automatically by
the declarations given in the XML file?
(I remember some years back, I've used some open-source parser [maybe
xerces] that did exactly that when some option was set.)
Thanks for any pointers!
Bye,
Tassilo