Sax

determining type

Page 1 of 1

6 Replies - 1963 Views - Last Post: 18 November 2002 - 10:48 AM Rate Topic: -----

#1 Noffke  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 497
  • Joined: 09-August 02

Sax

Posted 14 August 2002 - 07:31 AM

Has anyone ever used the SAX Parser to parse XML files? If so , is there a function to determine the type of DTD an XML file uses?

Right now the user specifies what parser to send the XML file to, but I would like to add a little warning to the user in case the XML file is not supposed to go to the parser that the user specified. Or perhaps make my interface smart enough to send the file to the correct parser without the user specifying. I really just wish that everyone would decide on a standard XML format for this stuff, but that is probably too much to ask.....

Noffke :music:

Is This A Good Question/Topic? 0
  • +

Replies To: Sax

#2 Patricio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-August 02

Re: Sax

Posted 16 August 2002 - 10:11 AM

I had DTD problems parsing XML using the Python language (the parser completely skipped over the DTD). It may save some headaches to just do a quick parse of the file yourself to just check if the file is valid, then if it's valid, feed it to the SAX parser. I'd assume all you're looking for is one line early in the file, so that shouldn't be too huge of a task.

Also if you have a choice I'd suggest using DOM instead of SAX to parse XML. It's much easier and more elegant.
Was This Post Helpful? 0
  • +
  • -

#3 Noffke  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 497
  • Joined: 09-August 02

Re: Sax

Posted 18 August 2002 - 01:38 PM

Too late for a change in the parser at this stage, but SAX seems to work well. I guess ignorance is bliss. Thanks for the tip...

Noffke B)
Was This Post Helpful? 0
  • +
  • -

#4 Patricio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-August 02

Re: Sax

Posted 19 August 2002 - 09:52 AM

Bleh it's never too late :P. I had to rewrite a fully functional XML that used SAX once, so that it would use DOM just because the people directing my project didn't want to maintain SAX code. :blink:
Was This Post Helpful? 0
  • +
  • -

#5 Patricio  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-August 02

Re: Sax

Posted 20 August 2002 - 07:51 AM

And now I eat my words as my job requires me to write a SAX parser in Java =P.
Was This Post Helpful? 0
  • +
  • -

#6 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: Sax

Posted 21 August 2002 - 02:39 PM

*snicker* ^_^
Was This Post Helpful? 0
  • +
  • -

#7 Noffke  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 497
  • Joined: 09-August 02

Re: Sax

Posted 18 November 2002 - 10:48 AM

ok, i know this thread is old, but this forum is so dead, and i think it needs some action.

I put this problem on the back burner, cause we decided to wait until this quarter to address this problem.

I ended up making an abstract class that both the different xml readers could extend, then I made another xml reader that tested for an element that was unique in each xml type. when the new xml reader was instantiated its only purpose was to figure out the type of xml file being dealt with and store it. Then when I call getIdentity from that class or any of the xmlreader classes it returns the identity of the file being parsed. Now I can send the file to the correct parser and the user can pass either xml standard to the program.

Noffke
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1