Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3492068
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:42:49+00:00 2026-05-18T11:42:49+00:00

Recently I was studying about parsers including the design patterns used to built one.

  • 0

Recently I was studying about parsers including the design patterns used to built one. The example I have chosen is javax.xml.parsers and org.w3c.dom packages.

Looks like factory and builder patterns used to design the parser structure in these packages. DocumentBuilderFactory is to return an immediate factory to build DocumentBuilder. DocumentBuilder, then, uses its parse() method to parse an xml file; but the return type is Document in this case: Document doc = builder.parse(in);

But, what I didn’t get here is Document is an interface which contains plenty of methods to manipulate XML attributes. It also extends Node interface. We can still call its operations: doc.hasAttributes() or doc.getChildNodes() etc.

I spent an hour on this, but still couldn’t get the logic behind this architecture:

1) Where are those Document’s methods implemented?

2) Why is it better to return interface type object (Document) to represent the DOM object after parsing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:42:49+00:00Added an answer on May 18, 2026 at 11:42 am

    Document, Node, Element and all of the other types are interfaces. There are a couple of libraries around that provide an implementation for those interfaces – one prominent example is Apache Xerces. From their front page:

    Xerces2 also provides a complete implementation of the Document Object Model Level 3 Core and Load/Save W3C Recommendations and provides a complete implementation of the XML Inclusions (XInclude) W3C Recommendation.

    If you exactly need to know which implementation of DOM is actually used, start a debugger or dump the class name of your Document object to the console/log.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently started studying about threads. I thought of starting from the beginning
Recently I have started studying about memory leaks in C++, so I may ask
I've recently begun my journey of learning CSS, and have been studying Gmail's design,
Recently, I was studying about throwing our own exceptions and I thought that maybe
I've recently been studying TDD, attended a conference and have dabbled in few tests
I have been studying python for quite sometime now and very recently I decided
Recently i came to know about Rx framework and seems very promising. I have
I've been studying Python 3 recently and I have come across a conundrum: I
I have recently started studying Google Web Toolkit. I have went through some walkthroughs,
I have been recently studying code for In-App-Billing v2. And have found some issues

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.