creating xml within java app

T

TP

Hi,

I have reached a situation where I have to create small pieces of xml
(around 8k characters) within my java app. Right now I am using
stringbuffer to create the xml which does not go against a dtd. This
is working for now, since I do not have to read in the xml again.

But if I wanted to use some other xml utility like xerces or jdom, is
it recommended for my use of xml or would it be an overkill. Please
let me know.

Thanks.

tP
 
M

Martin SChukrazy

Validation of an xml document is not required when parsing (you can use
non-validating parser's).
So the question is do you need to validate the xml document (against a dtd)
you just created or not for a particular reason.
If the xml document is used for external interfacing (process or system)
then it would be wise to validate the xml you created.
If it is not intended for that purpose then you must decide whether its
worth the extra processing step...

Hope this helps...
 
T

TP

Martin,

Thanks for replying. As of this point, validation is not required. So
in my case is it wise to move towards actually creating an xml
document using the DOM or SAX OR what I am doing with StringBuffer is
enough for my needs. Basically the xml created is passed through an
XSLT transformation.

Thanks.

TP.
 
M

Martin SChukrazy

The only reason you would want to use DOM or SAX etc would be to ensure a
well-formed XML (conformant to a Schema). So if you dont need this then why
bother ? what you are doing with the string buffer is quite sufficient for
now. However if you want the absolute correct way to do is to validate your
XML document once you create it, sort of an error checking for debugging...

The advantage of validating the xml you just created would be to make sure
all the elements required are present and that the XSLT transformation does
not fail for that purpose (kinda like a debugging step).
The disadvantage is that it requires additional processing & work (again
dependent on the system) to get this working.
So the question is do you think the advantages outweigh the disadvantages?
Is your system able to catch errors in the data flow before and after the
XSLT transformation?
 
T

TP

The xslt transform does catch malformed xml. So I think I am going to
be staying with stringbuffer. thanks for the comments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,821
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top