• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

XML as inbound data?

Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking at the prospect of dealing with inbound XML data. By that I mean that we will receive invoices, contracts, customer info etc... from other businesses that we will load into our database.
I was wondering if any design patterns for OOAD/Java would apply to building the Java application and how we validate the XML content and write it to our persistent database. I have some ideas but I'd like some other POV. Also, I want to consider the possibility of accepting new XML structures (i.e. products) and how I can build an extensible/robust java program to handle the current XML structures and that will adapt readily to new structures as the system grows.
Thanks in advance for any input!
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whenever you have an incoming stream, you will have to ensure structural integrity using a Schema or a DTD. One exception however, is if you are always receiving XML input from "trusted sources"
You might want to read this discussion about error handling scenarios.
Once you receive the XML, you will have to "cook" an object ( or objects ) out of it so that it can be processed and persisted in the DB. Eventhough you can achieve this today the hardway, there are some interesting and developments going on in this arena such as XML databainding. These frameworks seamlessly "unmarshall" XML nodes into objects and vice-versa. They take the clue from the DTD/Schema and generate the class blueprint.
Once objects are created you can use any pluggable or proprietary persistence framework to write them to the DB.
Here are some links -
Databinding from XML to Java Applications
JSR XML Databinding specification
The JAXB by Sun is still under development, but it has the potential to evolve as a very robust XML tool. Its initial version will support only DTDs.

Hope I have (atleast partially ) answered your question.

Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SQL and XML to allow formatting & input of XML data...
A great quote I picked up from David A. Taylor is �Objects themselves are naturally adoptive units of software, but they lose all their flexibility if they are locked into conventional applications.� (Object Technology: A Manager�s Guide, 1998, Addison-Wesley) That is why I was so surprised in the Harrisburg Java User group this month when I saw a very neat demo using XML within an old-style SQL data-extract statement, contradicting this axiom.
With the advent of new DB Tables called UDB (Universal DataBase) tables now being provided by several vendors which allow pictures, documents and XML docs to be stored with regular data-fields within a table, there is some real flexibility. And now SQL (Structured Query Language) is now able to handle the new XML formats.
The astounding demo I saw was using the SAX parser in a custom Java function to return parts of an �XML field� within a regular database table. It was also using SQL!
In Oracle 8i, I was very impressed to see the SQL statement "select xmlutil.getNode( 'STATE', xml-Doc-field ) from file-name" use a custom Java method "getNode" to extract a field from an XML document which was stored in a field of a UDB table.
This timed as being 20% faster than using PL SQL string manipulation. And a data base trigger (like a record add) can also force this Java Function. So by adding an empty record containing only an XML document into your table, you would set off parser functions to auto-load all the other fields in the table.
Similarly, IBM�s DB2 XML Extender can store an XML in a field or provide a link or pointer from a table field to an external document (eg. a picture of a product) and even if the file is moved within the scope of the file system, the link is not broken, but remains intact. It can also map XML fields to regular fields or index the XML fields by use of a DAD (Document Access Definition). This IBM product is available for DB2 on AIX, Sun, Linux, NT, but not iSeries AS/400. (Redbook SG24-6130-00, Dec 2000). This approach also makes embedded XML documents appear within regular database SQL extractions.
So, Oracle�s use of Java within SQL contradicts David A. Taylor�s assumption. And IBM�s innovative approach melding SQL and XML is something to make the rest of us sit up and take notice.

iSeries AS400 Java
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic