Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Why namespace information is not in attributes list

Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am user Xerces 1.4 SAX parser. In my content handler, I need to print out the root element exactly the same as the original XML file I am parsing. Following is the code I used:
public void startElement(....) {
for(int i=0; i<atts.getLength(), i++)
System.out.print(" " + atts.getName(i) + "=" + atts.getValue(i));
When the root element have no namespace informaion, the print out looks perfect:
<root ID="5">
printout from my code:
<root ID="5">
but, when I add some namespace information into the root element, the print out is not what I expected:
xsi:schemaLocation=" order.xsd"

now the print out is:
xsi:schemaLocation=" order.xsd"

here, I missed two lines from the original xml file. I tried to debug my code, and found that the xml=... and xml:xsi=... was not listed in the atts as attribute name/value pair. What's the reason? How to fix my problem?
Thanks for any comments.
What's wrong? Where are you going? Stop! Read this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic