• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

characters() callback for empty elements

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody know a SAX implementing parser which fires "character()" callback even for empty elements ?
Thank you,
Srini
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know of any, and it seems a very strange requirement. Remember that in XML, <a></a> is treated exactly the same as <a/>. Would you want an empty character string in both cases?
If I need to know whether any characters were supplied, I set a flag if any characters are supplied, and check it when I am notified of the end tag.
 
Alagu Seenivasan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This indeed is a strange requirement because I need to convert the xml into a fixed length text file where,if the element is not present there should be so many blanks. So after looking around I had already done exactly what you said.
In the "startelement" set a flag and remember the supposed length
and reset the flag in the "characters". check the flag in the "endelement" and do accordingly.
I know that the firing "characters" call back is (parser) implementation dependent.
My problem is solved for the time being. If I come across a better solution, I will post it here.
Thanks Frank.
[This message has been edited by Alagu Seenivasan (edited October 02, 2000).]
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alagu,
I would like to know how you solved the problem.
 
Alagu Seenivasan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assumption: characters() callback is not automatically fired for empty elements.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!