Quick followup...

Ooops...I reset my computer and it's now working as a charm :-)
Something went wrong in my Websphere...

Andrea, thank you very very much for your time and help.


----- Original Message -----
From: "Josema Alonso" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, November 14, 2002 4:47 PM
Subject: Re: how to get rid of the xml declaration on results?


> Dear Andrea,
>
> Thanks for your help. I already solved it but I'm not satisfied with the
> solution. I had to get the results as String and clean them first.
>
> Btw, I've tested your function, and I already had one very very similar,
and
> I still have a DOM exception in this line with both:
> Element resElement =
> ((Document)((XMLResource)r).getContentAsDOM()).getDocumentElement();
>
> The exception said DOM003: Wrong Document.
>
> So, I'll use my solution from now on, 'til I could correct that error or
> find a better one.
>
> Thanks again :-)
>
>
>
> ----- Original Message -----
> From: "Andrea Broglia" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Thursday, November 14, 2002 5:18 AM
> Subject: RE: how to get rid of the xml declaration on results?
>
>
> > Hi Josema,
> >   I don't know if you're still struggling with the query results to
strip
> > away the xml declaration and the added attributes, but this may help
you:
> >
> >   public Document combineXPathResults(String resultRootElement,
> >                                       ResourceSet result)
> >     throws XMLDBException
> >   {
> >     // Create a new Document and a root element that will have as
children
> >     // all the results
> >     Document resultDoc = new DocumentImpl();
> >     Element root = resultDoc.createElement(resultRootElement);
> >     resultDoc.appendChild(root);
> >
> >     // Iterate the xpath results and add each of them to the main
Document
> >     ResourceIterator iterator = result.getIterator();
> >     while(iterator.hasMoreResources()) {
> >       Resource r = iterator.nextResource();
> >
> >       Element resElement = ((Document)
> >         ((XMLResource)r).getContentAsDOM()).getDocumentElement();
> >
> >       // Remove unwanted attributes
> >       resElement.removeAttribute("src:col");
> >       resElement.removeAttribute("src:key");
> >       resElement.removeAttribute("xmlns:src");
> >
> >       // Add this result to the root element
> >       Element importedElement =
(Element)resultDoc.importNode(resElement,
> > true);
> >       root.appendChild(importedElement);
> >     }
> >
> >     return resultDoc;
> >   }
> >
> > Once you have the "global" result Document object you can serialize it
> > (using the XMSerialize class), or apply an xslt to it (using Xalan), or
> > anything you need to.
> >
> > Cheers,
> >   Andrea
> >
> >
> > > -----Original Message-----
> > > From: Josema Alonso [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, 14 November 2002 3:02 AM
> > > To: [email protected]
> > > Subject: Re: how to get rid of the xml declaration on results?
> > >
> > >
> > > Hey,
> > >
> > > Remember the weird characters? The function below, which is really
> stupid,
> > > makes the parse work, just by rewriting the characters from the XML
> string
> > > with the same ones. So, I'm now sure it is an encoding issue, and I do
> not
> > > know how to fix other way. Any ideas on how to retrieve the
> > > resources in the
> > > right encoding?
> > >
> > > Thanks.
> > >
> > > -------------
> > > /**
> > >  * Removes those nasty characters from the resource
> > >  *
> > >  */
> > > private String removeNasty(String data) throws
> > > UnsupportedEncodingException
> > > {
> > >  char oldChar = new String("\n").charAt(0);
> > >  char newChar = new String("\n").charAt(0);
> > >  data = data.replace(oldChar, newChar);
> > >
> > >  newChar = new String("\t").charAt(0);
> > >  oldChar = new String("\t").charAt(0);
> > >  data = data.replace(oldChar, newChar);
> > >
> > >  return data;
> > > }
> >
>

Reply via email to