Closed neywen closed 7 years ago
Hé Loïc ! 👘
I'm afraid there is no support for writing neither XSD nor DTD information in xeumeuleu. The rationale up to now has been that it can be done easily enough manually. For instance a schema can be set with
xos << xml::prefix( "http://www.w3.org/2001/XMLSchema-instance", "xsi" )
<< xml::ns( "http://www.w3.org/2001/XMLSchema-instance" )
<< xml::attribute( "noNamespaceSchemaLocation", "some_schema_uri.xsd" );
A DTD can be set beforehand in the output, granted you will need to manually create a destination standard stream and wrap it in an xml::xostreamstream
std::stringstream os;
os << "<!DOCTYPE element SYSTEM 'some_document_type.dtd'>\n";
{
xml::xostreamstream xos( os );
xos << xml::start( "element" );
}
auto s = os.str();
That being said I am of course open to pull requests should you feel the urge to contribute 🤗
right ! I believe this is simple enough to not require another API update, thanks for the tip.
I'm having difficulties to handle the xml::xostreamstream, though. I look at the sources, and I don't understand how I can output it to a string or a file. I guess I'm blind....
xml::xostreamstream simply adapts an std::ostream so either an std::stringstream or an std::ofstream. I updated the example in my previous comment to provide a more comprehensive example for outputting to a string, Similarly for a file this would look like
std::ofstream os( "some_file.xml" );
os << "<!DOCTYPE element SYSTEM 'some_document_type.dtd'>\n";
xml::xostreamstream xos( os );
xos << xml::start( "element" );
thanks for the help, Mat !
Hi Mat,
Thanks for xeumeuleu, it's great ! I've been trying to look for a way to include a DTD link into an xml output string. Could not find any hint in the documentation. Am I missing something ?
Thanks for any tip, cheers, loïc b :)