[xsd-users] Saving Partial XSD trees
Paul McGrath
paul.s.mcgrath at gmail.com
Fri Oct 28 08:45:13 EDT 2022
Thanks for the pointer. I was able to use the FAQ and add the following
code to the Set function. This allows the output file to be also the input
file which is exactly that I wanted.
Thanks again for your help.
Paul
xml_schema::dom::auto_ptr<::xercesc::DOMDocument> doc(
impl->createDocument(
xml::string(ns).c_str(),
xml::string("" + name).c_str(),
0));
::xercesc::DOMElement * root(doc->getDocumentElement());
root->setAttributeNS(
xml::string("http://www.w3.org/2000/xmlns/").c_str(),
xml::string("xmlns:xsi").c_str(),
xml::string("http://www.w3.org/2001/XMLSchema-instance
").c_str());
root->setAttributeNS(
xml::string("http://www.w3.org/2000/xmlns/").c_str(),
xml::string("xmlns:xsd").c_str(),
xml::string("http://www.w3.org/2001/XMLSchema").c_str());
root->setAttributeNS(
xml::string("http://www.w3.org/2001/XMLSchema-instance
").c_str(),
xml::string("xsi:noNamespaceSchemaLocation").c_str(),
xml::string("matml31_lib.xsd").c_str());
xml_schema::element_map::serialize(*doc->getDocumentElement(),
*res);
// Serialize the DOM document to XML using the serialize() function
// from dom-serialize.hxx.
//
//std::cout << "response:" << std::endl
// << std::endl;
serialize(/*std::cout*/ofs, *doc);
On Fri, Oct 28, 2022 at 4:34 AM Boris Kolpackov <boris at codesynthesis.com>
wrote:
> Paul McGrath <paul.s.mcgrath at gmail.com> writes:
>
> > I have been able to input the file and output the file, however the
> output
> > is missing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:noNamespaceSchemaLocation="matml31_lib.xsd" in the element when you
> > compare it to the input file.
>
> With custom serialization via DOM, you need to add these attributes
> yourself.
>
More information about the xsd-users
mailing list