Java XML Parser

Joerg Brunsmann joerg.brunsmann@FernUni-Hagen.de
Mon Nov 15 08:08:00 GMT 1999


Hi,

XP is an XML Parser in Java by James Clark. If you follow
these simple steps you can compile it with gcj:

$ mkdir xml
$ cd xml

Download from

  http://www.jclark.com/xml/xp/index.html

the file "xp.zip" and save it in the xml dir.

Download from

  http://www.megginson.com/SAX/

the file "saxjava-1.0.zip" and save it in the xml dir.

$ unzip xp.zip
$ rm -rf docs
$ rm -f xp.jar xp.zip
$ unzip saxjava-1.0.zip
$ rm -f *.java *.txt *.class sax.jar saxjava-1.0.zip
$ rm -rf javadoc

Verify thet you have two subdirectories named 'org' and 'com'.
Copy the attached makefile into the xml dir.
Edit the location of the gcj and gcjgc libraries (first line
in the makefile).

$ make classfiles
$ make prepare
$ make
$ make apps
(Here you see the only error message:
com/jclark/xml/apps/Doctype.java:16: sorry, not implemented: : `anonymous array' JDK1.1(TM) feature
)
$ cd com/jclark/xml/apps
$ ./Time file.xml

or

$ ./Normalize file.xml 

Enjoy,

Jörg

Here's the makefile:

LDFLAGS=-L/home/joerg/libgcj/lib

SAX=org/xml/sax
SAX_HELPERS=$(SAX)/helpers
XML=com/jclark/xml
XML_UTIL=com/jclark/util
XML_APPS=$(XML)/apps
XML_TOK=$(XML)/tok
XML_SAX=$(XML)/sax
XML_OUTPUT=$(XML)/output
XML_PARSE=$(XML)/parse
XML_PARSE_IO=$(XML_PARSE)/io
XML_PARSE_BASE=$(XML_PARSE)/base


OBJS=\
$(SAX)/AttributeList.o \
$(SAX)/DTDHandler.o \
$(SAX)/DocumentHandler.o \
$(SAX)/EntityResolver.o \
$(SAX)/ErrorHandler.o \
$(SAX)/HandlerBase.o \
$(SAX)/InputSource.o \
$(SAX)/Locator.o \
$(SAX)/Parser.o \
$(SAX)/SAXException.o \
$(SAX)/SAXParseException.o \
$(SAX_HELPERS)/AttributeListImpl.o \
$(SAX_HELPERS)/LocatorImpl.o \
$(SAX_HELPERS)/ParserFactory.o \
$(XML)/Version.o \
$(XML_UTIL)/Hashtable.o \
$(XML_UTIL)/Hashtable_Enumerator.o \
$(XML_TOK)/ASCIIEncoding.o \
$(XML_TOK)/Buffer.o \
$(XML_TOK)/ContentToken.o \
$(XML_TOK)/EmptyTokenException.o \
$(XML_TOK)/Encoding.o \
$(XML_TOK)/EndOfPrologException.o \
$(XML_TOK)/ExtensibleTokenException.o \
$(XML_TOK)/ISO8859_1Encoding.o \
$(XML_TOK)/InternalEncoding.o \
$(XML_TOK)/InvalidTokenException.o \
$(XML_TOK)/PartialCharException.o \
$(XML_TOK)/PartialTokenException.o \
$(XML_TOK)/Position.o \
$(XML_TOK)/PrologParser.o \
$(XML_TOK)/PrologSyntaxException.o \
$(XML_TOK)/SingleByteEncoding.o \
$(XML_TOK)/StringConversionCache_Bucket.o \
$(XML_TOK)/StringConversionCache.o \
$(XML_TOK)/TextDecl.o \
$(XML_TOK)/Token.o \
$(XML_TOK)/TokenException.o \
$(XML_TOK)/UTF16BigEndianEncoding.o \
$(XML_TOK)/UTF16LittleEndianEncoding.o \
$(XML_TOK)/UTF8Encoding.o \
$(XML_TOK)/XmlDecl.o \
$(XML_OUTPUT)/SyncXMLWriter.o \
$(XML_OUTPUT)/UTF8XMLWriter.o \
$(XML_OUTPUT)/UTF8XMLWriter_ReplacementTextOutputStream.o \
$(XML_OUTPUT)/XMLWriter.o \
$(XML_SAX)/CommentDriver_1.o \
$(XML_SAX)/CommentDriver.o \
$(XML_SAX)/Driver.o \
$(XML_SAX)/Locator.o \
$(XML_SAX)/ReaderInputStream.o \
$(XML_SAX)/WrapperException.o \
$(XML_PARSE_IO)/Application.o \
$(XML_PARSE_IO)/ApplicationImpl.o \
$(XML_PARSE_IO)/Parser.o \
$(XML_PARSE_IO)/ParserImpl.o \
$(XML_PARSE_BASE)/Application.o \
$(XML_PARSE_BASE)/ApplicationImpl.o \
$(XML_PARSE_BASE)/Parser.o \
$(XML_PARSE_BASE)/ParserImpl.o \
$(XML_PARSE)/ApplicationException.o \
$(XML_PARSE)/AttributeDefinition.o \
$(XML_PARSE)/CharacterDataEvent.o \
$(XML_PARSE)/CommentEvent.o \
$(XML_PARSE)/DTD.o \
$(XML_PARSE)/DocumentParser.o \
$(XML_PARSE)/ElementType.o \
$(XML_PARSE)/EndCdataSectionEvent.o \
$(XML_PARSE)/EndDocumentTypeDeclarationEvent.o \
$(XML_PARSE)/EndElementEvent.o \
$(XML_PARSE)/EndEntityReferenceEvent.o \
$(XML_PARSE)/EndPrologEvent.o \
$(XML_PARSE)/Entity.o \
$(XML_PARSE)/EntityManager.o \
$(XML_PARSE)/EntityManagerImpl.o \
$(XML_PARSE)/EntityParser.o \
$(XML_PARSE)/EntityParser_DTDImpl.o \
$(XML_PARSE)/EntityParser_DeclState.o \
$(XML_PARSE)/EntityParser_ElementTypeImpl.o \
$(XML_PARSE)/EntityParser_ElementTypeImpl_Attribute.o \
$(XML_PARSE)/EntityParser_EntityImpl.o \
$(XML_PARSE)/EntityParser_StartExternalSubsetEvent.o \
$(XML_PARSE)/LocatedEvent.o \
$(XML_PARSE)/MarkupDeclarationEvent.o \
$(XML_PARSE)/MessageId.o \
$(XML_PARSE)/Messages.o \
$(XML_PARSE)/NotWellFormedException.o \
$(XML_PARSE)/OpenEntity.o \
$(XML_PARSE)/ParseLocation.o \
$(XML_PARSE)/ParserBase.o \
$(XML_PARSE)/ProcessingInstructionEvent.o \
$(XML_PARSE)/StartCdataSectionEvent.o \
$(XML_PARSE)/StartDocumentTypeDeclarationEvent.o \
$(XML_PARSE)/StartElementEvent.o \
$(XML_PARSE)/StartEntityReferenceEvent.o 



all: $(OBJS)

apps: 
	gcj --main=com.jclark.xml.apps.Time $(LDFLAGS) -o $(XML_APPS)/Time $(OBJS) $(XML_APPS)/Time.java
	gcj --main=com.jclark.xml.apps.Normalize $(LDFLAGS) -o $(XML_APPS)/Normalize $(OBJS) $(XML_APPS)/Normalize.java
	gcj --main=com.jclark.xml.apps.Doctype $(LDFLAGS) -o $(XML_APPS)/Doctype $(OBJS) $(XML_APPS)/Doctype.java


$(SAX)/%.o: $(SAX)/%.class
	gcj -c -o $@ $<

$(SAXHELPERS)/%.o: $(SAXHELPERS)/%.class
	gcj -c -o $@ $<

$(XML_UTIL)/%.o: $(XML_UTIL)/%.class 
	gcj -c -o $@ $<

$(XML)/%.o: $(XML)/%.class 
	gcj -c -o $@ $<


$(XML_TOK)/%.o: $(XML_TOK)/%.class 
	gcj -c -o $@ $<

$(XML_SAX)/%.o: $(XML_SAX)/%.class 
	gcj -c -o $@ $<


$(XML_PARSE_IO)/%.o: $(XML_PARSE_IO)/%.class 
	gcj -c -o $@ $<


$(XML_OUTPUT)/%.o: $(XML_OUTPUT)/%.class 
	gcj -c -o $@ $<


prepare:
	cp '$(XML_UTIL)/Hashtable$$Enumerator.class' $(XML_UTIL)/Hashtable_Enumerator.class
	cp '$(XML_PARSE)/EntityParser$$EntityImpl.class' $(XML_PARSE)/EntityParser_EntityImpl.class
	cp '$(XML_PARSE)/EntityParser$$ElementTypeImpl.class' $(XML_PARSE)/EntityParser_ElementTypeImpl.class
	cp '$(XML_PARSE)/EntityParser$$ElementTypeImpl$$Attribute.class' $(XML_PARSE)/EntityParser_ElementTypeImpl_Attribute.class
	cp '$(XML_PARSE)/EntityParser$$DTDImpl.class' $(XML_PARSE)/EntityParser_DTDImpl.class
	cp '$(XML_PARSE)/EntityParser$$StartExternalSubsetEvent.class' $(XML_PARSE)/EntityParser_StartExternalSubsetEvent.class
	cp '$(XML_PARSE)/EntityParser$$DeclState.class' $(XML_PARSE)/EntityParser_DeclState.class
	cp '$(XML_OUTPUT)/UTF8XMLWriter$$ReplacementTextOutputStream.class' $(XML_OUTPUT)/UTF8XMLWriter_ReplacementTextOutputStream.class
	cp '$(XML_TOK)/StringConversionCache$$Bucket.class' $(XML_TOK)/StringConversionCache_Bucket.class
	cp '$(XML_SAX)/CommentDriver$$1.class' $(XML_SAX)/CommentDriver_1.class

clean:
	rm -f $(OBJS)

classfiles:
	javac -classpath . com/jclark/util/Hashtable.java\
 com/jclark/xml/sax/*.java\
 com/jclark/xml/*.java\
 com/jclark/xml/apps/*.java\
 com/jclark/xml/parse/base/*.java\
 com/jclark/xml/parse/io/*.java\
 com/jclark/xml/parse/*.java\
 com/jclark/xml/tok/*.java\
 com/jclark/xml/output/*.java


More information about the Java mailing list