There is no requirement to use the XML API to create an XML document. Since
XML is just a text document, it is easy to create it with simple programs
with print statements or even in a text editor. In fact, it is often faster
to create XML the way you have by coding the output statements. Further, the
API will not validate the XML Document against a DTD or Schema as it is
being created.
There are advantages to using the API. It will always produce well-formed
XML. It will escape less-than and greater-than characters that appear as
data values. You would have to do this yourself. It can be convenient to
have the document data structure.
I prefer to create XML using the API. I think the positives outweigh the
overhead. But, there is no requirement to use it.
Brian Dudley
Director, Consulting
CGI
--------------
Hi,
well..the string which has been written on to the file has the exact syntax
of the XML file...
The folder where the XML file..(myxml.xml) is generated via the
'fileoutputstream' as shown in the code.Teh DTD also lies int he same
folder...hence..i get a valid ,well-formed XML file...whcih i can use...this
is wierd..but it works all right
----- Original Message -----
From: "Balamuthukumar Namasivayam" <[EMAIL PROTECTED]>
To: "JDJList" <[EMAIL PROTECTED]>
Sent: Thursday, May 23, 2002 11:55 AM
Subject: [jdjlist] Re: Xml generation
>
> How do u validate your xml file against DTD or Schema withour using XML
> parser?.For generating XML file you no need to have a parser.
>
> Regards
>
> Bala
> Mobile 0415 654 273
> Office 02-8845 8617
>
>
>
>
>
> "saurabh"
> <skedia@itil. To: "JDJList"
<[EMAIL PROTECTED]>
> com> cc:
> Subject: [jdjlist] Xml
generation
> 2002/05/23
> 16:12
> Please
> respond to
> "JDJList"
>
>
>
>
>
>
> Hi all,
> I have used a strange approach to generating XML based on data retrieved
> from database and have consequently displayed it in HTML format using XSL
>
> here is the code ihave used:
>
> Properties pEnv = new Properties();
> pEnv.load(new FileInputStream("C:
> \\jboss-2.4\\tomcat\\webapps\\ROOT\\jspxml\\abc.dtd"));//loaded my DTD
file
> in same directory where my XML file will be generated
>
> try{
> *****Creating a string that looks like XML*****
>
> String xmlG="<?xml version=\"1.0\" ?>\n";
> xmlG=xmlG+"<!DOCTYPE abc >\n\n";
> xmlG=xmlG+"<abc>\n";
>
> v5=remote1.getEmployeeNames();//fetching data from database and writng
it
> as part of string using EJB method call
> for(int i=0;i<v5.size();i++)
> {
> vRow=new Vector();
> vRow=(Vector)v5.elementAt(i);
>
> xmlG=xmlG+"<people>\n"+
> "<person>\n"+
> "<name>\n"+
> "<firstname>"+(String)vRow.get(1)+"</firstname>\n"+
> "<lastname>"+(String)vRow.get(2)+"</lastname>\n"+
> "<ecn>"+(String)vRow.get(0)+"</ecn>\n"+
> "</name>\n"+
>
> "</person>\n"+
> "</people>";
> }
>
> xmlG=xmlG+"</abc>";
>
> ******making a xml file using the String*****
>
> FileOutputStream f= new FileOutputStream
> ("C:/jboss-2.4/tomcat/webapps/ROOT/jspxml/myxml.xml");
> DataOutputStream d= new DataOutputStream(f);
> d.writeBytes(xmlG);
>
> }catch(Exception ex)
> {
> out.println(" Exceptionin in exp.jsp: "+ex);
> }
>
> response.sendRedirect("bookdata.jsp");//here,the xml file generated
> together with xsl(written separately) is being converted into html format
> for display using Taglibs.
> %>
> I have not used any XML parser for the xml generation ...this works...I
had
> also written a DTD .
> Is this the correct approach...what would the negative implications
> be...can anyone comment..
>
> thanks in advance,
> Saurabh
>
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
>
>
>
>
> ------------------------------------------
> This e-mail is confidential. If you are not the intended recipient, any
use, disclosure or copying of this document is unauthorised and prohibited.
If you have received this document in error, please delete the email and
notify me by return email or by phoning the NEMMCO Helpdesk on 1300 300 295.
>
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
>
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm