• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

First XML project with quick turnaround

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I recently received a project involving XML and could use some guidance since my understanding of XML is very basic. The full requirements of the project are unknown at this time though I do have enough information to start prototyping.

I am looking for any pointers or guidance that you may provide that will put me on the right track, since I don�t have a lot of time to educate myself with how Java and XML work together.

Project description:
On a daily basis an XML service sheet and various court documents are received in a folder. The service sheet will contain the names of the court documents and other info pertaining to each court document.

My Java program will load the XML file and parse it to assure it is well-formed. Once this check passes, the application will iterate through the parsed document and verify that every document specified in the XML file is in fact stored in the folder.

The contents of the XML service sheet will look something like the following, though the exact contents of the file are unknown at this time. I do know there will be a filename attribute for each document type.

<xml>
<petitions>
<petition>
<filename>petition1.pdf</filename>
<number>1412-08</number>
<taxpayer>Fred B. Miller</taxpayer>
<filingdate>08/12/2008</filingdate>
</petition>
<petition>
<filename>petition2.pdf</filename>
<number>1413-08</number>
<taxpayer>Phil D. Bloughman</taxpayer>
<filingdate>08/12/2008</filingdate>
</petition>
<petition>
<filename>petition3.pdf</filename>
<number>1414-08</number>
<taxpayer>Acme International Corporation</taxpayer>
<filingdate>08/12/2008</filingdate>
</petition>
</petitions>
<calendars>
<calendar>
<filename>calendar1.pdf</filename>
<judge>Judy M. Hatchett</judge>
<location>Philadelphia</location>
</calendar>
<calendar>
<filename>calendar2.pdf</filename>
<judge>Betty V. Hosenberry</judge>
<location>Boston</location>
</calendar>
</calendars>
<orders>
<order>
<filename>order1.pdf</filename>
<number>1056-08</number>
<taxpayer>Barney J. Smith</taxpayer>
<issueddate>08/12/2008</issueddate>
</order>
<order>
<filename>order2.pdf</filename>
<number>1334-08</number>
<taxpayer>XYZ Corporation</taxpayer>
<issueddate>08/12/2008</issueddate>
</order>
<order>
<filename>order3.pdf</filename>
<number>1401-08</number>
<taxpayer>Lou H. Reed</taxpayer>
<issueddate>08/12/2008</issueddate>
</order>
</orders>
</xml>

Ideally I am looking for guidance on the Java API�s that:
1. Determine if a document is well formed
2. Can parse/retrieve the filename attribute for all occurrences in the XML file

All help is greatly appreciated
Thanks Jim
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The standard Java parsers will fail if the document is not well-formed. Some extra work is necessary to check for validity against a DTD or another kind of schema.

In my opinion, the easiest way to read the values of the filename elements will be to parse the document into an XML Document object, then use XPath to extract the data you need. There are some examples in this article at IBM developerWorks.
 
Jim Carey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carey,
thanks for the info. Based on your advice I have a working prototype.

thanks
 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic