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 9089539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:10:25+00:00 2026-06-16T22:10:25+00:00

We have a bog-standard javax.xml.* parser that slurps up a big XML file and

  • 0

We have a bog-standard javax.xml.* parser that slurps up a big XML file and tries to validate it against a custom DTD. The DTD is stored locally, and we’re validating using transformers like in this post from some years back.

All of that works. The trouble we’re seeing now is that the XML format for this type of file is written by the devil. I’m not kidding; the specification is over 750 pages and is signed “Love, Satan.”

Specifically, part of the XML looks like this:

<KnownTag>
    <ArbitraryTag> ... text ... </ArbitraryTag>
    <Whatever>     ... text ... </Whatever>
    <fj9e8jer23tj> ... text ... </fj9e8jer23tj>
    ....
</KnownTag>

The inner tags are balanced — the raw syntax is known to be well-formed XML at this point — but the element names themselves are completely arbitrary and unpredictable. (Yes, it’s that evil. The company that originally published this spec has long since gone out of business because their products were notoriously unreliable. Go figure.)

Our custom DTD can specify <!ELEMENT KnownTag ANY>, but we’re having fits with the content. Obviously the validating parser gives errors as soon as it hits the first user-specified element name (element type “ArbitraryTag” must be declared), and obviously we can’t truly “validate” anything inside that block from a purely parsing context. I’m hoping to find some way of suppressing the errors for just that section of XML.

  • The parser’s error handler interface, ErrorHandler, specifies 3 callbacks; its error() is called in this case. If I can figure out from the actual exception passed in that we’re inside a KnownTag block, then I can safely ignore the error and keep going. Is this safe to do with the Java SE implementation?

  • Getting to the arbitrary elements afterwards shouldn’t be a problem, since the XML parser itself has already built a DOM Document by this point.

  • The API for javax.xml.parsers.DocumentBuilder[Factory] and javax.xml.transform.Transformer don’t seem to permit toggling DocumentBuilderFactory#setValidating() midway through the parse. If that’s the case it won’t be surprising, but I’m hoping that I’ve just missed something. Anyone?

  • 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-06-16T22:10:27+00:00Added an answer on June 16, 2026 at 10:10 pm

    DTDs have no mechanism for skipping validation on particular subtrees of well-formed XML; that’s one of the differences between DTDs and later schema languages like XSD and Relax NG, which introduce wildcards to make it possible to say things like “The KnownTag element can contain arbitrary XML” (or: arbitrary elements not in a particular namespace, or in any of a particular set of namespaces, or …).

    Whether your parser has a facility to turn error reporting off in a particular subtree is entirely parser-specific; you’ll need to describe just which of the many Java-based XML parsers you are using. The chances are slim; it’s not impossible for a parser to have such a feature, but at first description it doesn’t sound like spec-conformant behavior. (It’s also not a feature I’ve ever heard of a DTD-based validator having, but that doesn’t actually prove much.)

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

Sidebar

Related Questions

We have a website that uses a bog-standard default sitemap with security trimming as
i have an xml file that contains lots of different nodes. some in particularly
Say I have a bog-standard Win32 popup menu, and it's taller than the screen.
Im using the bog standard form validation plugin. I have two radio buttons 'yes'
Have a problem that seems easy on paper but i'm having a big problem
I have a custom control that extends ASP.NET Update panels. On the server side
I have a bog-standard Visual Studio Express Visual C++ environment, installed on a bog-standard
I have written a little bog standard asp.net mvc3 app in vs web express
We have your bog standard Java app under development, and a lot of the
I have a base controller to DRY up a lot of my bog standard

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.