[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
Sun Oct 21 22:21:35 EDT 2007


Hi Boris & all,

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,
Take xsde 1.1.0 as an example, I will modify 
xsde/cxx/parser/elements.hxx  
xsde/cxx/parser/elements.hxx  
to add a flag in class parser_base to control whether do namespace
checking during parsing:

      struct parser_base
      {
        // ....
        bool getNamespaceCheck() { return bNamespaceCheck; }
        void setNamespaceCheck(bool b) { bNamespaceCheck = b; }
        private:
          bool bNamespaceCheck;
       // ....
      };

And then I will modify the generated parser files as below:
Before:
if (n == "display-name" &&
                 ns == "urn:oma:xml:poc:list-service" )
)
After:
if (n == "display-name" &&
                ( !getNamespaceCheck() || ns ==
"urn:oma:xml:poc:list-service" )
)

By doing this, I can config whether doing namespace check when
constructing the parsers. 
But is there a better way to do this?
I can't modify the schemas definitions, cause I still need namespace
checking when parsing a WHOLE xml document, 
Only with xml fragments I don't want namespace checking.

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().

Thank you!

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





More information about the xsde-users mailing list