Umm, well, after reviewing the source, I imagine that the exception you're seeing is 
DOMException::NOT_SUPPORTED_ERR.  Apparently DOMBuilder doesn't do what you want.  
This is probably because it's an experimental (and incomplete) implementation.  Maybe 
it'll get better when the final specification is implemented.  The spec is 
considerably different from the draft the experimental implementation is based on.  
For instance, DOMBuilder and DOMInputSource were changed to LSParser and LSInput 
respectively in the final spec.

An alternative approach may be in order.  XercesDOMParser has a parse method that 
accepts an InputSource.  You could pass it a LocalFileInputSource after setting the 
encoding.

On the other hand, it's possible that we're both missing something.  Questions for 
all: is DOMBuilder incomplete, as it appears?  Are there plans to implement the final 
DOM 3 LS recommendation?  Last I heard, Gareth suggested that work might start on DOM 
3 Core, at least, following the release of 2.6, but I don't recall any further 
discussion.

> -----Original Message-----
> From: Heeg, Michael [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 01, 2004 10:12 AM
> To: '[EMAIL PROTECTED]'
> Cc: Heeg, Michael
> Subject: AW: Question concerning DOMBuilder and encoding
> 
> Hi Jesse,
> 
> thanks for your advice. I tried, but I failed. Please see 
> below the code
> fragment.
> The part which creates the pointer to the DOMImplementation 
> succeeds (impl
> != NULL),
> but the line
> "DOMInputSource* myDOMSource = impl->createDOMInputSource  ();"
> throws an exception.
> Any idea?
> 
> Regards,
> Michael Heeg
> 
> 
> try {
>       XMLCh temp[100];
>       XMLString::transcode("LS", temp, 99);   
>       
>       //create DOM Implementation
>       DOMImplementationLS* impl =
> DOMImplementationRegistry::getDOMImplementation(temp);
>       
>       XMLCh* test = XMLString::transcode(m_xmlPath.data());
>       
>       DOMInputSource* myDOMSource = impl->createDOMInputSource  ();
> 
>       myDOMSource->setEncoding(XMLString::transcode("iso-8859-1"));
>       m_domDoc = m_domBuilder->parse(*myDOMSource);
> }
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Jesse Pelton [mailto:[EMAIL PROTECTED]
> > Gesendet: Mittwoch, 1. September 2004 15:20
> > An: [EMAIL PROTECTED]
> > Betreff: RE: Question concerning DOMBuilder and encoding
> > 
> > 
> > Looking at the documentation, it appears that 
> > DOMBuilder::parse(const DOMInputSource &source) should allow 
> > you to do what you want.  You'll need to construct the input 
> > source first, of course.  As part of that process, you can 
> > call DOMInputSource::setEncoding().
> > 
> > > -----Original Message-----
> > > From: Heeg, Michael [mailto:[EMAIL PROTECTED] 
> > > Sent: Wednesday, September 01, 2004 9:08 AM
> > > To: [EMAIL PROTECTED]
> > > Cc: Heeg, Michael
> > > Subject: Question concerning DOMBuilder and encoding
> > > 
> > > Hi everybody,
> > > 
> > > I have a problem with parsing a local file into a DOM. I 
> > > found out that the
> > > reason is the encoding the DOMBuilder uses (UTF-8 by 
> > > default?), but I did
> > > not find a way how to change it.
> > > 
> > > The problem is, that the local file has NO header line 
> > which sets the
> > > encoding like
> > > "<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>"
> > > If I add this line to the local file, the parsing works 
> > fine. But if I
> > > delete this line, the parsing process terminates with an 
> > > exception, because
> > > the document contains special characters like "°C" for degree 
> > > Celsius. And:
> > > due to compatibility it is not possible to include the header 
> > > line in the
> > > local files.
> > > 
> > > My question: is it possible to set the encoding the 
> > > DOMBuilder should use
> > > outside of the local file?
> > > 
> > > Thanks for your help!
> > > 
> > > Best regards,
> > > Michael Heeg
> > > 
> > > 
> > > Here are some fragments of my sources:
> > > 
> > > //member variables
> > > DOMDocument* m_domDoc;
> > > DOMBuilder* m_domBuilder;
> > > 
> > > //set external schema path
> > > XMLCh* propVal = XMLString::transcode("c:\myschema.xsd");
> > > m_domBuilder->setProperty(XMLUni::fgXercesSchemaExternalNoName
> > > SpaceSchemaLoc
> > > ation, propVal);
> > > 
> > > //parse document, transfer into the DOMDocument
> > > m_domDoc = m_domBuilder->parseURI("c:\myfile.txt");

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to