WG: [xsd-users] XSD Parsing with different schema files

Lickert, Dominik (LEN, DivHG) DLickert at testo.de
Mon Nov 28 10:18:03 EST 2011


Hi Boris,

Please read first the mail from 15:02, also added in the following.

I debug the code a few times more and found out that "a_" has no member called "release". "a_" is a " xercesc_3_1::DOMAttr *" - type and consists of the parameter:
- fNamespaceURI  ->  "http://www.w3.org/XML/1998/namespace"	(const wchar_t *)
- fLocalName  ->   "space"	(const wchar_t *)
- fPrefix  ->  "xml"	(const wchar_t *)

I hope this helps you.

Dominik


-----Ursprüngliche Nachricht-----
Von: Lickert, Dominik (LEN, DivHG) 
Gesendet: Montag, 28. November 2011 15:02
An: 'Boris Kolpackov'
Cc: xsd-users at codesynthesis.com
Betreff: AW: [xsd-users] XSD Parsing with different schema files

Hi Boris,

-----Ursprüngliche Nachricht-----
Von: Boris Kolpackov [mailto:boris at codesynthesis.com]
Gesendet: Freitag, 25. November 2011 07:12
An: Lickert, Dominik (LEN, DivHG)
Cc: xsd-users at codesynthesis.com
Betreff: Re: [xsd-users] XSD Parsing with different schema files

Hi Dominik,

In the future please keep your replies CC'ed to the xsd-users mailing list as discussed in the posting guidelines:

http://www.codesynthesis.com/support/posting-guidelines.xhtml

Lickert, Dominik (LEN, DivHG) <DLickert at testo.de> writes:

> I think that isn't the solution. I tried to build my project with both 
> variants, but also without success. I have an example of the XML file 
> of Visio. The three separated schema files are linked to the xml file 
> in the root element. For reminder: They are linked only in the XML 
> file, not in the schema files!!!
> The elements of the two other schema files, of the namespace 
> "extension",
> are:
> 	- "Event"
> 	- "Layout"
> 	- "Protection"
> (The content of the elements with a "+" in front of is comment out!!!)

I looked at the schemas and indeed they use the first approach I described (wildcards). In particular, look at the vx:Event element under the Shape element in your sample XML. This element is allowed by the xsd:any wildcard in ShapeSheet_Type (visio.xsd, line 157).


> My problem is now that the parsing process is interrupted at the point 
> of the element '<vx:Event xmlns:vx="http://schemas.microsoft.com/visio/2006/extension"> '.
> At this point the parser go back to the element "Shape" and parse the 
> next element after "Shape", in this case the element "Icon".

I am not sure what you mean by "interrupted". If you compiled your schemas with the --generate-wildcard option (and following other instructions from the 'wildcard' example), then the content corresponding to the vx:Event element will be stored in the object model as a DOM fragment. This fragment can then be parsed into the object model fragment, again, as shown in the 'wildcard' example.


> I hope now it's more clear what I meant. Please ask if not, it's 
> difficult to explain.
> 
> I added the three schema files.
> The download-link of the schema files is here:
> http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23
> 976
> 
> One further problem are errors during the building. The point the 
> redefinition of a lot of classes. I know that one solution is to map 
> them with the "--namespace-map" attribute, but I think this is the 
> wrong way, isn't it? I think this is the information to the solution.

The vision.xsd schema declarations are placed into the 'core' C++ namespace, while both visio12.xsd and visio14.xsd are both mapped to the 'extension' C++ namespace. So, yes, you will need to use the --namespace-map option to map the last two files to different C++ namespaces.

Boris




I built my source- and headerfiles with the wildcard option. But now I get some new problems. First for reminding my command line of my files visio.xsd, visio12.xsd and visio14.xsd generated by Visual Studio:

xsd.exe cxx-tree --generate-serialization --generate-wildcard --output-dir "." --hxx-suffix ".hxx" --cxx-suffix ".cxx" --ixx-suffix ".ixx" --fwd-suffix "-fwd.hxx" 
xsd.exe cxx-tree --generate-serialization --generate-wildcard --output-dir "." --hxx-suffix ".hxx" --cxx-suffix ".cxx" --ixx-suffix ".ixx" --fwd-suffix "-fwd.hxx" --namespace-map "http://schemas.microsoft.com/visio/2006/extension=vx"
xsd.exe cxx-tree --generate-serialization --generate-wildcard --output-dir "." --hxx-suffix ".hxx" --cxx-suffix ".cxx" --ixx-suffix ".ixx" --fwd-suffix "-fwd.hxx" --namespace-map "http://schemas.microsoft.com/office/visio/2010/extension=v14" 

I tried parsing a xml or vdx file with the generated source- and headerfiles and the following code:
auto_ptr<VisioDocument_Type> DocEmpty (VisioDocument(ifsEmptMaster));

I get the errors:
Error: no declaration found for element 'VisioDocument'
Error: attribute 'key' is not declared for element 'VisioDocument'
And so on ...

After searching in the archive for solutions, I tried parsing without validation:
auto_ptr<VisioDocument_Type> DocEmpty (VisioDocument(ifsEmptMaster, xml_schema::flags::dont_initialize));

But the program interrupts in the debugger mode in the file "parsing-source.txx" (containing path: xsd-3.3.0-i686-windows\libxsd\xsd\cxx\xml\dom) at line 116 and 117:
          // Get an implementation of the Load-Store (LS) interface.
          //
          DOMImplementation* impl (
            DOMImplementationRegistry::getDOMImplementation (ls_id));

Next solution I tried, was to link the schema file during parsing:
xml_schema::properties Props;
Props.no_namespace_schema_location ("file://" + std::string (cwd) + "visio.xsd"); Props.schema_location ("http://schemas.microsoft.com/visio/2003/core","visio.xsd");
auto_ptr<VisioDocument_Type> DocEmpty (VisioDocument(ifsEmptMaster, 0, Props ));

...

std::ofstream ofs ("visio.xml");
core::VisioDocument(ofs, *DocEmpty, map); cout << "end of SaveAsXml" << endl; }

But the program interrupts in the debugger mode in the file "containers-wildcard.hxx" at line 826:
        struct entry
        {
          ~entry ()
          {
            if (a_)
==>    a_->release ();   <==
          }

But in the code above it doesn't interrupt during the serialization function, but after the code! So the ouput "end of SaveAsXml" is printed in my output window. The map variable consists of the three schema files. I tried it also without the map variable, and only with visio.xsd as content of the map variable, but always with the same interrupt.
The serialization works fine. I read the visio.xml file and there are also elements of the two other schema files. It doesn't matter which schema files I put in the map variable.
But another failure is, that the serialization-function only works onetime in the program. When I use it a second time in my code, with another filename, it doesn't work.

Have you an idea, why the program interrupts at that point?

Thank you,
Dominik

Testo AG, Lenzkirch, Commercial Register Freiburg 320456 - Board of Directors: Burkart Knospe (CEO), Lothar Walleser, Martin Winkle, Dr. Jörk Hebenstreit- Supervisory board: Anne-Kathrin Deutrich (Chairperson), Klaus Fritzsching, Hartmut Herrlinger, Testo AG, Testo-Strasse 1, 79853 Lenzkirch, Germany



More information about the xsd-users mailing list