XML Serialization: Putting Stylesheet tag inside XML file
Hi,
Using XML serialization I have created an XML file which I want to see through a browser using a stylesheet.
So I want to put a statement :
<?xml-stylesheet type="text/xsl" href="XSLTFile.xsl"?>
in between below 2 statements :
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
like this :
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<?xml-stylesheet type="text/xsl" href="XSLTFile.xsl"?>
<!DOCTYPE boost_serialization>
File XSLTFile.xml contain stylesheet info. * So, how is it possible to put a stylesheet related statement just after the 1st statement? * Another query is, how to change the the tag name "boost_serialization" to something else?
You should be able to derive your new class from xml_archive_impl... There you can the initialization / windup functions. There is/was and outdated example of how to do this in the documentation using portable binary archive as an example. I don't know if it's still in there. Robert Ramey
Regards, Girish
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi,
I am able to insert the stylesheet tag from inside a constructor of my new derived class.
Please find below the whole program.
But, I am still getting an error :
terminate called after throwing an instance of 'std::bad_cast'
what(): std::bad_cast
Aborted (core dumped)
on the statement :
xa << BOOST_SERIALIZATION_NVP(e);
in the code below.
The statements :
xa.putTag ("TESTING_XMLCLASS");
xa << BOOST_SERIALIZATION_NVP(tmp);
oa << BOOST_SERIALIZATION_NVP(e);
work as expected.
Can you please let me know what could be the reason for this?
Regards,
Girish
# include <iostream>
#include <fstream>
#include <string>
#include
File XSLTFile.xml contain stylesheet info. * So, how is it possible to put a stylesheet related statement just after the 1st statement? * Another query is, how to change the the tag name "boost_serialization" to something else?
You should be able to derive your new class from xml_archive_impl... There you can the initialization / windup functions. There is/was and outdated example of how to do this in the documentation using portable binary archive as an example. I don't know if it's still in there. Robert Ramey
girish hilage wrote:
Hi,
I am able to insert the stylesheet tag from inside a constructor of my new derived class. Please find below the whole program.
But, I am still getting an error : terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Aborted (core dumped)
on the statement : xa << BOOST_SERIALIZATION_NVP(e); in the code below.
The statements : xa.putTag ("TESTING_XMLCLASS"); xa << BOOST_SERIALIZATION_NVP(tmp); oa << BOOST_SERIALIZATION_NVP(e); work as expected.
Can you please let me know what could be the reason for this?
I can't. The only thing that looks missing to me is:
#include
Hi,
I tried including
Hi,
I am able to insert the stylesheet tag from inside a constructor of my new derived class. Please find below the whole program.
But, I am still getting an error : terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Aborted (core dumped)
on the statement : xa << BOOST_SERIALIZATION_NVP(e); in the code below.
The statements : xa.putTag ("TESTING_XMLCLASS"); xa << BOOST_SERIALIZATION_NVP(tmp); oa << BOOST_SERIALIZATION_NVP(e); work as expected.
Can you please let me know what could be the reason for this?
I can't. The only thing that looks missing to me is:
#include
Hi Girish,
If you do get this problem solved, could you do me a favor and post the
solution, if you can. I was entertaining some similar requirement last year
for one of my projects.
Thanks in advance
Ganesh
On Thu, Feb 18, 2010 at 9:56 AM, girish hilage
Hi,
Using XML serialization I have created an XML file which I want to see through a browser using a stylesheet. So I want to put a statement : <?xml-stylesheet type="text/xsl" href="XSLTFile.xsl"?>
in between below 2 statements : <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization>
like this : <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml-stylesheet type="text/xsl" href="XSLTFile.xsl"?> <!DOCTYPE boost_serialization>
But the code for a init() function inside file boost/archive/impl/basic_xml_oarchive.ipp is as follows :
basic_xml_oarchive<Archive>::init(){ // xml header this->This()->put("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n"); this->This()->put("<!DOCTYPE boost_serialization>\n"); // xml document wrapper - outer root this->This()->put("
This()->put(">\n"); } File XSLTFile.xml contain stylesheet info. * So, how is it possible to put a stylesheet related statement just after the 1st statement? * Another query is, how to change the the tag name "boost_serialization" to something else?
Regards, Girish
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Ganeshram Iyer Open Source and CAD: http://ossandcad.blogspot.com ganeshramiyer@yahoo.com
participants (3)
-
Ganeshram Iyer
-
girish hilage
-
Robert Ramey