[xsde-users] How to config xsde to parse without namespace check / How to gain a better error message

Jiang, Bin (Bin) binjiang at alcatel-lucent.com
Wed Oct 24 12:40:50 EDT 2007


Hi Boris,

Really appreciate your timely and detailed response, thank you!
Please see my more questions below.

Thanks,
Jiang Bin (Bin)
GLMS Developer
Alcatel-Lucent

> -----Original Message-----
> From: Boris Kolpackov [mailto:boris at codesynthesis.com]
> Sent: 2007年10月23日 0:05
> To: Jiang, Bin (Bin)
> Cc: xsde-users at codesynthesis.com
> Subject: Re: [xsde-users] How to config xsde to parse without namespace
> check / How to gain a better error message
> 
> Hi Bin,
> 
> Jiang, Bin (Bin) <binjiang at alcatel-lucent.com> writes:
> 
> > Sometimes I need parsing a xml fragment without checking the namespace,
> > it there any convenient way to do this?
> > I've used XSD 2.1.1 2.3.0, and now xsde 1.1.0, my way is modifiy the xsd
> > library files and the generated parser files.
> 
> I think there is a more elegant way to accomplish this. The idea is
> to override the _start_element (and _start_attribute if necessary)
> low-level hook on the root parser and call the original version with
> a proper namespace when necessary:
> 
> virtual void
> _start_element (const xml_schema::ro_string& ns,
>                 const xml_schema::ro_string& name)
> {
>   if (need_to_add_namespace)
>   {
>     xml_schema::ro_string ns ("urn:oma:xml:poc:list-service");
>     base::_start_element (ns, name);
>   }
>   else
>   {
>     base::_start_element (ns, name);
>   }
> }
> 
> This will work because all events are going through the root
> element parser. This can get a bit more complicated if your
> vocabulary mixes qualified and unqualified elements. But
> normally it is either all qualified or only root element that
> is qualified and both of these cases are easy to handle with
> this method.
> 

[Jiang, Bin (Bin)] 
[Jiang, Bin (Bin)] This may not work if there is more than one namespace definitions in a instance document, right?

> > Another question is when there is an exception, like unexpected element
> > or attribute, how to get the namespace and name of the encountered
> > element or attribute, I only find there is line/column and text().
> 
> The current error propagation architecture makes it costly to pass
> this information up to the caller. Because of that we decided not
> to provide it. However, we are planning to change the inner workings
> of C++/Parser which will also make it fairly cheap to pass extra
> error information around and we will add support for names and
> namespaces then. Unfortunately, this is not planned for XSD/e 2.0.0
> (due in a couple of weeks) and will be implemented in XSD/e 2.1.0
> which is scheduled for the end of 2007 - beginning of 2008. How
> urgent is this feature for your project?

[Jiang, Bin (Bin)] 
[Jiang, Bin (Bin)] It's not so urgent now, since there is line/column information and we can always locate the error position. But if I can provide name or namespace, the error message would be more user-friendly and complete. Is there any work-around I can use? Performance is not a big issue for me at this moment, since from our performance testing results, xsde1.1.0(with --no-iostream) is good than xsd 2.1.1 which we used before.

> 
> Boris




More information about the xsde-users mailing list