problem with parsing xml with these jars: xercesImpl.jar and xml-apis.jar


after parsing the xml file I`m getting a Document object:

DocumentBuilder db =.....................
doc = db.parse(new StringBufferInputStream(source.toString()), url);  // source had the xml as string and the uri is set to the dtd directory

sposse this is the xml

     <one  name="first">
              <bbb value="4"/>

after doing the parse command somthing amazing happend:

it adding the bbb tag another attribute ( ligal one that mention in the dtd file) although I don`t need it now.
I remind you that Imust work with xercesImpl.jar and xml-apis.jar

how could I slove it ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zzynxSr. Software engineerCommented:
would you be so kind as to close (or react in) some of your old open questions?
>>it adding the bbb tag another attribute

What attribute?
aquaswAuthor Commented:
at the dtd there is serval of attributes that could be at this kind of tag.

after the parsing the bbb tag looks like:

<bbb secondvalue=".." value="4"/>

I don`t need the "secondvalue" attribute  , and didn`t add it to the bbb tag, but after the parsing it appears.
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Can you post the dtd?
aquaswAuthor Commented:
      value CDATA #REQUIRED
      secondvalue (yes | no) "no"
Don't know about this one i'm afraid
aquaswAuthor Commented:
well I think that  it goes over the dtd and add attributes acording to it.
The question is how could I prevent it ?
You can prevent it, because you specified this attribute in the DTD file. The "secondevalue" is always present as your DTD definition. You can modify your DTD like this:
     value CDATA #REQUIRED
     secondvalue #IMPLIED
The attribute secondvalue is OPTIONAL now, just use it when needed.
Hope this may help.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.