You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Rahul Srivastava <rs...@firstam.com> on 2003/05/14 07:37:28 UTC
RE: SAX Parsing [was: [PATCH] Allowing XMLSerializer to output
" (quotation mark) as it is]
> Vijay Karkala (RBIN/MDS) wrote...
>
> Hi Rahul
> thanks for the feedback
> can u point me tro the exact url?
I thought you have downloaded and installed Xerces! Okay. Go to:
http://xml.apache.org/dist/xerces-j/
and download Xerces-J-bin.2.4.0.whatever. Once you have downloaded the
binary, extract it to your local disk, e.g. C:\. Now, you can see the
Counter.java sample in C:\xerces-2_4_0\samples\sax\ directory. This program
SAX parses a XML file. You should write a similar program, but modify it to
write your own logic within the callbacks like startElement(...), etc, to
construct an appropriate SQL and fire it to the Database.
-Rahul.
> i think u r refering to some unix box(Xerces_HOME)
> (sorry im new to this forum just joined today)
> please could u give me some examples of java program that
> parses an XML document and inserts some of its data to database
> eagaerly awaiting ur response
> thanks
> vijay
>
> -----Original Message-----
> From: Rahul Srivastava [mailto:rsrivastava@firstam.com]
> Sent: Tuesday, May 13, 2003 6:45 PM
> To: xerces-j-dev@xml.apache.org
> Subject: RE: [PATCH] Allowing XMLSerializer to output " (quotation mark)
> as it is
>
>
> > Vijay Karkala (RBIN/MDS) wrote...
> >
> > does anyone of u have a sample code of parsing an XML document
> > using SAX parser in java and inserting the values to an
> oracle database
> > i am in urgent need of the same
>
> There is an excellent sample of SAX parsing a XML document in the samples
> bundled with Xerces. Have a look at $Xerces_HOME/samples/sax/Counter.java
>
> You need to change the logic in the various callbacks to
> construct a SQL of
> your taste and fire it to the DB.
>
> Hope that helps.
>
> -Rahul.
>
>
> >
> > -----Original Message-----
> > From: Ias [mailto:iasandcb@apache-korea.org]
> > Sent: Tuesday, May 13, 2003 6:07 PM
> > To: xerces-j-dev@xml.apache.org
> > Subject: RE: [PATCH] Allowing XMLSerializer to output "
> (quotation mark)
> > as it is
> >
> >
> > First of all, thank you for pointing out the issue. I tested the
> > following case with the previous patches:
> >
> > public void testXMLSerialize() throws Exception {
> > DOMImplementation di = db.getDOMImplementation();
> > Document doc =
> > di.createDocument("http://www.w3.org/XML/1998/namespace",
> "web", null);
> > Element webElement = doc.getDocumentElement();
> > webElement.setAttribute("test", "\"OK\"");
> > Text text = doc.createTextNode("\"Ias\"");
> > webElement.appendChild(text);
> > OutputFormat format = new OutputFormat(doc);
> > format.setLineSeparator(LineSeparator.Windows);
> > format.setIndenting(true);
> > format.setKeepTextNodeQuot(true);
> > XMLSerializer serializer = new XMLSerializer(System.out,
> > format);
> > serializer.serialize(doc);
> > }
> >
> > As you wrote, the result was not well-formed.
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web test=""OK"">"Ias"</web>
> >
> > I revisited printXMLChar method and made some approaches:
> >
> > 1. printXMLChar method has 2 slightly different versions.
> >
> > printXMLChar(int ch, boolean keepQuot) processes output.
> > printXMLChar(int ch) is a wrapper to call printXMLChar(int ch, false),
> > which brings you " all the time.
> >
> > 2. printText methods use printTextXMLChar method instead of
> > printXMLChar.
> >
> > printTextXMLChar method is to call printXMLChar(int ch, boolean
> > keepQuot) based on keepTextNodeQuot field of _format object.
> >
> > The patch attached to this message implements the above
> approaches. The
> > test result is
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <web test=""OK"">"Ias"</web>
> >
> > , which is well-formed naturally.
> >
> > The main idea is to differentiate text output from the other
> output such
> > as attribute value and namespace uri.
> >
> > Best Regards,
> >
> > Ias.
> >
> > -----Original Message-----
> > From: Elena Litani [mailto:elitani@ca.ibm.com]
> > Sent: Friday, May 09, 2003 4:23 AM
> > To: xerces-j-dev@xml.apache.org
> > Subject: Re: [PATCH] Allowing XMLSerializer to output "
> (quotation mark)
> > as it is
> >
> > Hi Ias,
> >
> > Thank you for looking into this problem.
> >
> > Unfortunately, the fix you provide will make serialize produce not
> > well-formed XML. The printXMLChar is used to print both -
> character data
> > and attribute values. If '"' appear in attribute value it must be
> > converted to " since attribute values serialized in
> double quotes.
> >
> > The correct fix would be to make serialize convert double
> quote to quot
> > reference only in attribute values, but avoid doing it for character
> > data. See REVISIT in printXMLChar method.
> >
> > If you can look into providing a correct patch that would be great!
> >
> > Thank you,
> > --
> > Elena Litani / IBM Toronto
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org